前几天linux系统上写个消费activemq消息的java程序时遇到这个错误,原因是linux系统的activemq客户端hostname引起,把hostname改为localhost可以决绝。但具体原因不是很明白。
下面提示中:BFG-OSER-273是访问activemq的客户端的hostname;
WARNING: could not generate unique stub
java.net.UnknownHostException: BFG-OSER-273: BFG-OSER-273
at java.net.InetAddress.getLocalHost(InetAddress.java:1353)
at org.apache.activemq.util.IdGenerator.<clinit>(IdGenerator.java:51)
at org.apache.activemq.ActiveMQConnection.<clinit>(ActiveMQConnection.java:108)
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:285)
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:253)
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:224)
at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:172)
at com.baofeng.activemqmonitor.consumer.AbstractConsumer.start(AbstractConsumer.java:67)
at com.baofeng.activemqmonitor.MainClass.main(MainClass.java:34)
Aug 18, 2010 7:31:54 PM org.apache.activemq.transport.failover.FailoverTransport doReconnect
INFO: Successfully connected to tcp://60.28.110.228:61616
javax.jms.JMSException: broker Cannot add a consumer to a session that had not been registered: ID:null0:0:-1
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49)
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1244)
at org.apache.activemq.AdvisoryConsumer.<init>(AdvisoryConsumer.java:50)
at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1348)
at org.apache.activemq.ActiveMQConnection.createSession(ActiveMQConnection.java:298)
at com.baofeng.activemqmonitor.consumer.AbstractConsumer.start(AbstractConsumer.java:68)
at com.baofeng.activemqmonitor.MainClass.main(MainClass.java:34)
Caused by: java.lang.IllegalStateException: broker Cannot add a consumer to a session that had not been registered: ID:null0:0:-1
at org.apache.activemq.broker.TransportConnection.processAddConsumer(TransportConnection.java:535)
at org.apache.activemq.command.ConsumerInfo.visit(ConsumerInfo.java:345)
at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:305)
at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:179)
at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68)
at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:143)
at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:206)
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:84)
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:203)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:185)
at java.lang.Thread.run(Thread.java:619)
Aug 18, 2010 7:31:54 PM org.apache.activemq.transport.failover.FailoverTransport handleTransportFailure
WARNING: Transport failed to tcp://60.28.110.228:61616 , attempting to automatically reconnect due to: java.io.EOFException