[英]ActiveMQ http connection error
I am trying to connect my java client application to ActiveMQ over http, but keep getting an error: (complete error at the bottom) 我试图通过http将我的Java客户端应用程序连接到ActiveMQ,但始终收到错误消息:(底部出现完整错误)
javax.jms.JMSException: Could not post command: ProducerInfo
No such field org.apache.activemq.command.ProducerInfo.sentCount
Also, there is connection to ActiveMQ, because the server also produces an error: (complete error at the bottom) 此外,由于服务器还会产生错误,因此连接到ActiveMQ :(底部完全错误)
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field
org.apache.activemq.command.ProducerInfo.sentCount
Is there a library or jar problem? 是否存在库或罐子问题?
This connections works why I connect with: tcp://localhost:61616 此连接有效,原因是我连接:tcp:// localhost:61616
activemq.xml activemq.xml中
<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>
jndi.properties in my Java Client program: 我的Java客户端程序中的jndi.properties:
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 Client Java客户端
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");
}
}
This works with tcp://localhost:61616 but not with http://localhost:8080 这适用于tcp:// localhost:61616,但不适用于http:// localhost:8080
Can any person help me get this thing up and running? 有人可以帮助我启动并运行该产品吗?
Client Error: 客户端错误:
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
SERVER ACTIVE MQ: 服务器活动MQ:
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)
I guess you are mixing different ActiveMQ version/packaging and one of them is 5.9.0
(or before). 我猜您正在混合使用不同的ActiveMQ版本/打包,其中之一是
5.9.0
(或5.9.0
版本)。 The field sentCount
exist since version 5.9.1
. 从
5.9.1
版本开始, sentCount
字段sentCount
存在。
5.9.0
was released on 14.Oct.2013 5.9.0
于2013年10月14日发布 sentCount
was added on 03.Dec.2013 sentCount
已于sentCount
年12月03日添加
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.