- STOMP plugin
rabbitmq-plugins enable rabbitmq_web_stomp rabbitmq-plugins enable rabbitmq_web_stomp_examplesThe demo example can be accessed through the link: http://127.0.0.1:15670/web-stomp-examples , but it is actually useless because the referenced jquery.min.js is a resource of google.
var mqStompUrl="http://192.168.174.131:15674/stomp"; var ws = new SockJS (mqStompUrl); // 使用 socket //var ws = new WebSocket("ws://192.168.174.131:15674/ws");//使用websocket var client = Stomp.over(ws); // SockJS does not support heart-beat: disable heart-beats client.heartbeat.incoming = 0; client.heartbeat.outgoing = 0; client.debug = function(e) { console.log(e); }; // default receive callback to get message from temporary queues client.onreceive = function(m) { console.log(m) } var on_connect = function(x) { id = client.subscribe("/queue/hehe",function(m) { //... }}); }; var on_error = function() { console.log('error'); }; client.connect('sheungxin', '123456', on_connect, on_error, '/'); client.send("/queue/hehe",{"content-type":"text/plain"}, text);The following error is reported when using websocket: failed: Error during WebSocket handshake: Unexpected response code: 404 , the reason
has . Please refer to: http://www.rabbitmq.com/web-stomp.html
- simple summary
/amq/queue/queuename: The difference from /queue/queuename is that the queue is not automatically created by stomp, and the queue does not exist. Failure
/ topic/routing_key: subscribe/publish messages through the amq.topic forwarder, create a temporary queue by default when subscribing, and bind the topic with routing_key
/temp-queue/xxx: create a temporary queue (only in the attribute reply in headers -to), which can be used to receive reply messages through a temporary queue after sending a message, and receive through client.onreceive
/exchange/exchangename/[routing_key]: subscribe/publish messages through the forwarder, the forwarder needs to manually create
client.subscribe(destination ,callback,headers): subscribe message
client.send(destination,headers,body): publish message
client.unsubscribe(id): cancel subscription, id is the number returned when subscribed
client.onreceive: default receive callback to get message from temporary queue
- Queue Properties support
- Chinese message cannot be sent