You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2019/01/21 15:10:07 UTC
[pulsar] branch master updated: Issue #3375 Websocket example not
working (#3393)
This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 7460e5a Issue #3375 Websocket example not working (#3393)
7460e5a is described below
commit 7460e5ad235981f1c633a8ed780991c15e7eb81f
Author: wpl <12...@qq.com>
AuthorDate: Mon Jan 21 23:09:59 2019 +0800
Issue #3375 Websocket example not working (#3393)
* Fix #3375 Websocket example not working
* Fix #3375 Websocket example not working
* Fix Websocket example not working
---
site/docs/latest/clients/WebSocket.md | 6 +++---
site/ja/clients/WebSocket.md | 23 +++++++++++++++++-----
site2/docs/client-libraries-websocket.md | 6 +++---
.../client-libraries-websocket.md | 6 +++---
.../version-2.2.0/client-libraries-websocket.md | 6 +++---
.../version-2.2.1/client-libraries-websocket.md | 6 +++---
6 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/site/docs/latest/clients/WebSocket.md b/site/docs/latest/clients/WebSocket.md
index a5e23f5..ca02c75 100644
--- a/site/docs/latest/clients/WebSocket.md
+++ b/site/docs/latest/clients/WebSocket.md
@@ -368,7 +368,7 @@ Here's an example Node.js {% popover producer %} that sends a simple message to
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/producer/persistent/my-tenant/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/producer/persistent/public/default/my-topic",
ws = new WebSocket(topic);
var message = {
@@ -396,7 +396,7 @@ Here's an example Node.js {% popover consumer %} that listens on the same topic
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/consumer/persistent/my-tenant/my-ns/my-topic1/my-sub",
+ topic = "ws://localhost:8080/ws/v2/consumer/persistent/public/default/my-topic/my-sub",
ws = new WebSocket(topic);
ws.on('message', function(message) {
@@ -410,7 +410,7 @@ ws.on('message', function(message) {
#### NodeJS reader
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/reader/persistent/my-tenant/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/reader/persistent/public/default/my-topic",
ws = new WebSocket(topic);
ws.on('message', function(message) {
diff --git a/site/ja/clients/WebSocket.md b/site/ja/clients/WebSocket.md
index e4aadef..007fac8 100644
--- a/site/ja/clients/WebSocket.md
+++ b/site/ja/clients/WebSocket.md
@@ -262,7 +262,7 @@ Pulsarの{% popover_ja トピック %}に簡単なメッセージを送信する
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/producer/persistent/my-property/us-west/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/producer/persistent/public/default/my-topic",
ws = new WebSocket(topic);
var message = {
@@ -275,20 +275,19 @@ var message = {
};
ws.on('open', function() {
- // 1つのメッセージを送信します
- ws.send(JSON.stringify(message));
+ // 1つのメッセージを送信します
+ ws.send(JSON.stringify(message));
});
ws.on('message', function(message) {
console.log('received ack: %s', message);
});
-
```
#### NodeJS Consumer
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/consumer/persistent/my-property/us-west/my-ns/my-topic1/my-sub",
+ topic = "ws://localhost:8080/ws/v2/reader/persistent/public/default/my-topic/my-sub",
ws = new WebSocket(topic);
socket.onmessage = function(packet) {
@@ -297,3 +296,17 @@ socket.onmessage = function(packet) {
socket.send(JSON.stringify(ackMsg));
};
```
+
+#### NodeJS reader
+```javascript
+var WebSocket = require('ws'),
+ topic = "ws://localhost:8080/ws/v2/reader/persistent/public/default/my-topic",
+ ws = new WebSocket(topic);
+
+ws.on('message', function(message) {
+ var receiveMsg = JSON.parse(message);
+ console.log('Received: %s - payload: %s', message, new Buffer(receiveMsg.payload, 'base64').toString());
+ var ackMsg = {"messageId" : receiveMsg.messageId};
+ ws.send(JSON.stringify(ackMsg));
+});
+```
\ No newline at end of file
diff --git a/site2/docs/client-libraries-websocket.md b/site2/docs/client-libraries-websocket.md
index 72a6151..39ddf0c 100644
--- a/site2/docs/client-libraries-websocket.md
+++ b/site2/docs/client-libraries-websocket.md
@@ -389,7 +389,7 @@ Here's an example Node.js producer that sends a simple message to a Pulsar topic
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/producer/persistent/my-tenant/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/producer/persistent/public/default/my-topic",
ws = new WebSocket(topic);
var message = {
@@ -417,7 +417,7 @@ Here's an example Node.js consumer that listens on the same topic used by the pr
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/consumer/persistent/my-tenant/my-ns/my-topic1/my-sub",
+ topic = "ws://localhost:8080/ws/v2/consumer/persistent/public/default/my-topic/my-sub",
ws = new WebSocket(topic);
ws.on('message', function(message) {
@@ -431,7 +431,7 @@ ws.on('message', function(message) {
#### NodeJS reader
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/reader/persistent/my-tenant/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/reader/persistent/public/default/my-topic",
ws = new WebSocket(topic);
ws.on('message', function(message) {
diff --git a/site2/website/versioned_docs/version-2.1.0-incubating/client-libraries-websocket.md b/site2/website/versioned_docs/version-2.1.0-incubating/client-libraries-websocket.md
index 69e3dc5..d956e2c 100644
--- a/site2/website/versioned_docs/version-2.1.0-incubating/client-libraries-websocket.md
+++ b/site2/website/versioned_docs/version-2.1.0-incubating/client-libraries-websocket.md
@@ -356,7 +356,7 @@ Here's an example Node.js producer that sends a simple message to a Pulsar topic
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/producer/persistent/my-tenant/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/producer/persistent/public/default/my-topic",
ws = new WebSocket(topic);
var message = {
@@ -384,7 +384,7 @@ Here's an example Node.js consumer that listens on the same topic used by the pr
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/consumer/persistent/my-tenant/my-ns/my-topic1/my-sub",
+ topic = "ws://localhost:8080/ws/v2/consumer/persistent/public/default/my-topic/my-sub",
ws = new WebSocket(topic);
ws.on('message', function(message) {
@@ -398,7 +398,7 @@ ws.on('message', function(message) {
#### NodeJS reader
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/reader/persistent/my-tenant/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/reader/persistent/public/default/my-topic",
ws = new WebSocket(topic);
ws.on('message', function(message) {
diff --git a/site2/website/versioned_docs/version-2.2.0/client-libraries-websocket.md b/site2/website/versioned_docs/version-2.2.0/client-libraries-websocket.md
index aad351c..6c252c7 100644
--- a/site2/website/versioned_docs/version-2.2.0/client-libraries-websocket.md
+++ b/site2/website/versioned_docs/version-2.2.0/client-libraries-websocket.md
@@ -356,7 +356,7 @@ Here's an example Node.js producer that sends a simple message to a Pulsar topic
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/producer/persistent/my-tenant/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/producer/persistent/public/default/my-topic",
ws = new WebSocket(topic);
var message = {
@@ -384,7 +384,7 @@ Here's an example Node.js consumer that listens on the same topic used by the pr
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/consumer/persistent/my-tenant/my-ns/my-topic1/my-sub",
+ topic = "ws://localhost:8080/ws/v2/consumer/persistent/public/default/my-topic/my-sub",
ws = new WebSocket(topic);
ws.on('message', function(message) {
@@ -398,7 +398,7 @@ ws.on('message', function(message) {
#### NodeJS reader
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/reader/persistent/my-tenant/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/reader/persistent/public/default/my-topic",
ws = new WebSocket(topic);
ws.on('message', function(message) {
diff --git a/site2/website/versioned_docs/version-2.2.1/client-libraries-websocket.md b/site2/website/versioned_docs/version-2.2.1/client-libraries-websocket.md
index e829c71..b199303 100644
--- a/site2/website/versioned_docs/version-2.2.1/client-libraries-websocket.md
+++ b/site2/website/versioned_docs/version-2.2.1/client-libraries-websocket.md
@@ -390,7 +390,7 @@ Here's an example Node.js producer that sends a simple message to a Pulsar topic
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/producer/persistent/my-tenant/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/producer/persistent/public/default/my-topic",
ws = new WebSocket(topic);
var message = {
@@ -418,7 +418,7 @@ Here's an example Node.js consumer that listens on the same topic used by the pr
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/consumer/persistent/my-tenant/my-ns/my-topic1/my-sub",
+ topic = "ws://localhost:8080/ws/v2/consumer/persistent/public/default/my-topic/my-sub",
ws = new WebSocket(topic);
ws.on('message', function(message) {
@@ -432,7 +432,7 @@ ws.on('message', function(message) {
#### NodeJS reader
```javascript
var WebSocket = require('ws'),
- topic = "ws://localhost:8080/ws/v2/reader/persistent/my-tenant/my-ns/my-topic1",
+ topic = "ws://localhost:8080/ws/v2/reader/persistent/public/default/my-topic",
ws = new WebSocket(topic);
ws.on('message', function(message) {