我使用嵌入式代理 ActiveMq 并从 JavaScript 应用程序连接到它。使用的协议是 STOMP over WebSocket。Spring 的 XML 配置:
<amq:broker id="broker" useJmx="false" persistent="false" brokerId="1" brokerName="locHost">
<amq:transportConnectors>
<amq:transportConnector name="websocket" uri="ws://0.0.0.0:6661"/>
</amq:transportConnectors>
</amq:broker>
<!-- JMS ConnectionFactory to use, configuring the embedded broker using XML -->
<amq:connectionFactory id="jmsFactory" brokerURL="vm://localhost"/>
<bean id="jmsConnectionFactory"
class="org.springframework.jms.connection.SingleConnectionFactory"
depends-on="broker"
p:targetConnectionFactory-ref="jmsFactory"
/>
<jms:listener-container
container-type="default"
connection-factory="jmsConnectionFactory"
>
. . . . .
<jms:listener destination="toggle" ref="consumer" method="toggle" response-destination="toggle"/>
. . . . .
</jms:listener-container>
也有一些这种形式的听众(其中之一):
@Component
public class Consumer {
. . . . .
public String toggle(String message) {
return "Responce" + message;
}
. . . . .
}
一些侦听器正在工作,但有些侦听器存在异常类型:
09:33:25,196 WARN [Transport:203] Transport Connection to: StompSocket_1661562307 failed: java.io.IOException: closedOut 1006:null
并且消息没有到达收件人。我们能做什么?