Websocket消息传递间歇性

时间:2014-11-18 11:34:19

标签: java rabbitmq spring-websocket

我正在使用带有RabbitMQ和STOMP的Spring 4 websocket。我的经纪人xml是:

<websocket:message-broker application-destination-prefix="/app">
    <websocket:stomp-endpoint path="/ws">
      <websocket:sockjs/>
    </websocket:stomp-endpoint>
     <websocket:stomp-broker-relay prefix="/topic"
           relay-host="${websocket.relay.host}" relay-port="61613" client-login="XXXX" client-passcode="XXXX" system-login="XXXX" system-passcode="XXXX"
           heartbeat-send-interval="20000" heartbeat-receive-interval="20000"/>
     <!-- <websocket:simple-broker prefix="/topic"/> -->

     <websocket:client-inbound-channel>
<websocket:executor core-pool-size="50" max-pool-size="100" queue-capacity="100" keep-alive-seconds="60"/>
</websocket:client-inbound-channel>
<websocket:client-outbound-channel>
<websocket:executor core-pool-size="50" max-pool-size="100" queue-capacity="100" keep-alive-seconds="60"/>
</websocket:client-outbound-channel>
<websocket:broker-channel>
<websocket:executor core-pool-size="50" max-pool-size="100" queue-capacity="100" keep-alive-seconds="60"/>
</websocket:broker-channel>

  </websocket:message-broker>

消息在客户端间歇性地丢失。我使用SimpMessagingTemplate将消息转发给代理。

我还将文本大小配置为:

<beans:bean class="org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean ">
        <beans:property name="maxTextMessageBufferSize" value="8192000"/>
        <beans:property name="maxBinaryMessageBufferSize" value="8192000"/>
    </beans:bean>

我无法理解从服务器到代理或代理到浏览器的消息都会丢失。

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

如果您的客户端或服务器消息大小使用标准的8Kb(8192字节),您可以通过以下方式增加大小:

Java SockJS Spring客户端和消息大小 Java SockJS Spring client and message size