Comments (4)
To create a durable subscriber, you must set the client-id
header on the connect and a subscription name on the subscribe call.
Which STOMP broker are you using? For ActiveMQ, you must set activemq.subscriptionName
to the subscription name (as documented in http://activemq.apache.org/stomp)
from stomp-websocket.
Excellently!Thanks a lot!
from stomp-websocket.
@greezen Can you please show me your code about it?
from stomp-websocket.
@Catechacha
use FuseSource\Stomp\Stomp;
$user = getenv("ACTIVEMQ_USER");
if( !$user ) $user = "admin";
$password = getenv("ACTIVEMQ_PASSWORD");
if( !$password ) $password = "password";
//$headers["client-id"]='das';
$consumer = new Stomp("tcp://192.168.0.101:61613");
$consumer->sync = false;
//$consumer->setReadTimeout(10);
$consumer->clientId = "tt1";
//var_dump($consumer->clientId);exit;
//var_dump($consumer->getSessionId());exit;
if(!$consumer->isConnected()){
echo 'begin';
$consumer->connect($user, $password,array('activemq.subcriptionName'=>'tt1' ));
// subscribe to the topic
$consumer->subscribe("/topic/tt1");
}
// receive a message from the topic
$msg = $consumer->readFrame();
// do what you want with the message
if ( $msg != null) {
echo "Message '$msg->body' received from topic\n";
$consumer->ack($msg);
} else {
echo "Failed to receive a message\n";
}
$consumer->unsubscribe('/topic/tt1');
$consumer->disconnect();
from stomp-websocket.
Related Issues (20)
- client send msg in a loop(loop<=200),the websocket disconnect.
- TypeError: undefined is not a constructor (evaluating 'new WebSocketClient()')
- how to user in nuxt?
- RabbitMQ Stomp Endpoint 404 Not Found http://127.0.0.1:15674/stomp HOT 2
- SignalR
- Please publish 2.3.4 version to npm repository HOT 2
- How to set prefetch count?
- Error related to durable and auto_delete settings HOT 1
- error:Uncaught Error: Cannot find module 'net' HOT 2
- subscribe inside forloop would not trigger call back HOT 1
- This Code seems to be useless!
- setting selector is ineffective
- Loosing the connection after few mins , STOMP Client <-> Spring framework
- Cannot be accessed “https://cdn.bootcdn.net/ajax/libs/stomp.js/2.3.3/stomp.min.js”
- the way to get 'now' function is wrong ?
- The connection is not established, and the server keeps sending "H" messages
- Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
- net module not found in stompjs
- the version was discontinued 2.3.4? HOT 1
- why subcribe failed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stomp-websocket.