尝试设置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