首页 > 代码库 > RabbitMQ概念及环境搭建(五)与web的整合

RabbitMQ概念及环境搭建(五)与web的整合

####################################
rabbitmq_web_stomp
####################################
处于试验阶段,同伙WebSocket兼容层SockJS时 Web Browser与RabbitMQ(rabbitmq-stomp)实时通讯,可用于实时的WEB应用
安装
sudo rabbitmq-plugins enable rabbitmq_web_stomp
测试
http://127.0.0.1:15674/stomp

使用

<script src=http://www.mamicode.com/"http://cdn.sockjs.org/sockjs-0.3.min.js"></script>
<script src=http://www.mamicode.com/"stomp.js"></script>
<script>
    var ws = new SockJS(‘http://127.0.0.1:15674/stomp‘);
    var client = Stomp.over(ws);
    [...]
        [...]
    var on_connect = function() {
        console.log(‘connected‘);
    };
    var on_error =  function() {
        console.log(‘error‘);
    };
    client.connect(‘guest‘, ‘guest‘, on_connect, on_error, ‘/‘);
    [...]

参考:
http://www.rabbitmq.com/web-stomp.html

RabbitMQ概念及环境搭建(五)与web的整合