我正在尝试将文本消息从一个摆动的重型客户端(使用 Apache ActiveMQ 库)发送到一个 glassfish 服务器实例,该实例似乎使用 OpenMQ 作为默认的 JMS 提供程序。
在我用于客户的非常源代码基本代码下方:
try {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("jms/SaisieQueueFactory");
connectionFactory.setBrokerURL("tcp://localhost:27676");
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("jms/SaisieQueue");
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
TextMessage message = session.createTextMessage("Score + 1");
producer.send(message);
session.close();
connection.close();
} catch(Exception ex) {
ex.printStackTrace();
}
- 我在 Glassfish 服务器的管理控制台 (JMS_PROVIDER_PORT) 的系统属性中找到了代理端口
- 部署 MessageDrivenBean 时已创建队列连接工厂和队列
- 现在客户端和 glassfish 实例在同一台计算机上运行,但我想让它们在两台不同的机器上工作(这就是我不使用 vm:// 作为传输协议的原因)
我得到了这些例外:
javax.jms.JMSException: Cannot send, channel has already failed: tcp://127.0.0.1:7676
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1395)
at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1481)
at org.apache.activemq.ActiveMQConnection.start(ActiveMQConnection.java:516)
at testdate.TestDate.main(TestDate.java:44)
Caused by: org.apache.activemq.transport.InactivityIOException: Cannot send, channel has already failed: tcp://127.0.0.1:7676
at org.apache.activemq.transport.AbstractInactivityMonitor.doOnewaySend(AbstractInactivityMonitor.java:282)
at org.apache.activemq.transport.AbstractInactivityMonitor.oneway(AbstractInactivityMonitor.java:271)
at org.apache.activemq.transport.TransportFilter.oneway(TransportFilter.java:85)
at org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:104)
at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68)
at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:81)
at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:86)
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1366)
... 3 more
- 我考虑了将 Glassfish 实例的 JMS 提供程序更改为 ActiveMQ 的解决方案,但如果可能的话,我想保留 OpenMQ
PS:我是 JMS 和 Java EE 框架的初学者