ActiveMQ http connection error
我正在尝试通过 http 将我的 java 客户端应用程序连接到 ActiveMQ,但不断收到错误消息:(底部的完整错误)
1 2 | javax.jms.JMSException: Could not post command: ProducerInfo No such field org.apache.activemq.command.ProducerInfo.sentCount |
另外,还有连接到ActiveMQ,因为服务器也报错:(底部完全错误)
1 2 | com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field org.apache.activemq.command.ProducerInfo.sentCount |
是否有库或 jar 问题?
这个连接有效,为什么我连接:tcp://localhost:61616
activemq.xml
1 2 3 4 5 6 7 8 | <broker> ... <transportConnectors> <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="http" uri="http://0.0.0.0:8081"/> </transportConnectors> ... </broker> |
我的 Java 客户端程序中的
jndi.properties:
1 2 3 4 5 | java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory #java.naming.provider.url = tcp://localhost:61616 java.naming.provider.url = http://localhost:8081 connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry queue.testQueue = testQueue |
Java 客户端
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | package be.jmshub.jmsremotejndiproducer; import javax.jms.JMSException; import javax.jms.Connection; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.Message; import javax.jms.Queue; import javax.jms.QueueConnectionFactory; import javax.naming.Context; import javax.naming.InitialContext; public class Producer { public static void main(String[] args) throws JMSException { System.out.println("JMS REMOTE PRODUCER: start"); try { // create a new intial context, which loads from jndi.properties file Context ctx = new InitialContext(); QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("connectionFactory"); Connection connection = factory.createConnection(); Queue queue = (javax.jms.Queue) ctx.lookup("testQueue"); Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(queue); System.out.println("JMS REMOTE PRODUCER: connected"); int count = 0; for (int i = 0; i < 5; i++) { String messageText ="This is message" + (i + 1); Message message = session.createTextMessage(messageText); System.out.println("JMS REMOTE PRODUCER: sending -" + messageText); producer.send(message); count += 1; } System.out.println("JMS REMOTE PRODUCER: total messages sent:" + count); // Clean up session.close(); connection.close(); } catch (Exception ex) { System.out.println("JMS REMOTE PRODUCER: EXCEPTION:" + ex.toString()); } System.out.println("JMS REMOTE PRODUCER: finished"); } } |
这适用于 tcp://localhost:61616 但不适用于 http://localhost:8080
任何人都可以帮助我启动并运行这个东西吗?
客户端错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | javax.jms.JMSException: Could not post command: ProducerInfo {commandId = 4, responseRequired = true, producerId = ID:pc-prd0170-57061-1434012164882-2:1:1:1, destination = queue://testQueue, brokerPath = null, dispatchAsync = false, windowSize = 0, sentCount = 0} due to: java.io.IOException: Failed to post command: ProducerInfo {commandId = 4, responseRequired = true, producerId = ID:pc-prd0170-57061-1434012164882-2:1:1:1, destination = queue:// testQueue, brokerPath = null, dispatchAsync = false, windowSize = 0, sentCount = 0} as response was: HTTP/1.1 500 No such field org.apache.activemq.command.ProducerInfo.sentCount ---- Debugging information ---- field : sentCount class : org.apache.activemq.command.ProducerInfo required-type : org.apache.activemq.command.ProducerInfo converter-type : com.thoughtworks.xstream.converters.reflection.ReflectionConverter path :/org.apache.activemq.command.ProducerInfo/sentCount line number : 15 version : null ------------------------------- [Cache-Control: must-revalidate,no-cache,no-store, Content-Type: text/html;charset=ISO-8859-1, Content-Length: 2251, Server: Jetty(7.6.7.v20120910)] org.apache.http.conn.BasicManagedEntity@1c222ae |
服务器活动 MQ:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | WARN | / com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field org.apache.activemq.command.ProducerInfo.sentCount ---- Debugging information ---- field : sentCount class : org.apache.activemq.command.ProducerInfo required-type : org.apache.activemq.command.ProducerInfo converter-type : com.thoughtworks.xstream.converters.reflection.ReflectionConverter path : /org.apache.activemq.command.ProducerInfo/sentCount line number : 15 version : null ------------------------------- at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.determineType(AbstractReflectionConverter.java:453) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:294) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234) at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65) at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66) at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50) at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134) at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32) at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1058) at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1042) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:913) at org.apache.activemq.transport.xstream.XStreamWireFormat.unmarshalText(XStreamWireFormat.java:57) at org.apache.activemq.transport.http.HttpTunnelServlet.doPost(HttpTunnelServlet.java:127) at javax.servlet.http.HttpServlet.service(HttpServlet.java:713) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:447) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) at org.eclipse.jetty.server.handler.GzipHandler.handle(GzipHandler.java:275) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1040) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:374) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:972) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:363) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:483) at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:931) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:992) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:745) |
我猜你正在混合不同的 ActiveMQ 版本/package,其中之一是
开始存在
-
版本
5.9.0 于 2013 年 10 月 14 日发布 -
字段
sentCount 于 2013 年 12 月 3 日添加