Glassfish Server 和 ActiveMQ 的问题:peer 没有发送他的有线格式

Trouble with Glassfish Server and ActiveMQ: peer did not send his wire format

我在尝试设置 JMSPublisher 和 JMSSubscriber 时遇到此错误

jndi.properties

java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url = tcp://localhost:4848?wireFormat.maxInactivityDurationInitalDelay=30000
topic.topic/flightStatus = flightStatus

Glassfish 服务器 运行 位于:http://localhost:4848

发布者:

JmsPublisher publisher= new JmsPublisher("ConnectionFactory", "topic/flightStatus");

...

public JmsPublisher(String factoryName, String topicName) throws JMSException, NamingException {
    Context jndiContext = new InitialContext();
    TopicConnectionFactory factory = (TopicConnectionFactory) jndiContext.lookup(factoryName);
    Topic topic = (Topic) jndiContext.lookup(topicName);
    this.connect = factory.createTopicConnection();
    this.session = connect.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    this.publisher = session.createPublisher(topic);
}

异常:

Exception in thread "main" javax.jms.JMSException: Wire format negotiation timeout: peer did not send his wire format.
    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.createSession(ActiveMQConnection.java:323)
    at org.apache.activemq.ActiveMQConnection.createTopicSession(ActiveMQConnection.java:1112)
    at com.mycompany.testejms.JmsPublisher.<init>(JmsPublisher.java:34)
    at com.mycompany.testejms.JmsPublisher.main(JmsPublisher.java:51)
Caused by: java.io.IOException: Wire format negotiation timeout: peer did not send his wire format.
    at org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:98)
    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)
    ... 5 more

该错误表明 ActiveMQ 客户端实际上并未与 ActiveMQ 代理通信。 Glassfish 可能正在侦听 http://localhost:4848,但显然那不是 ActiveMQ 代理正在侦听连接的地方。据我了解,端口 4848 是 Glassfish Web 管理控制台侦听连接的地方。请注意您提供的 URL 中的 http。默认情况下,ActiveMQ 监听端口 61616.