gpt4 book ai didi

java - ActiveMQ http 连接错误

转载 作者:可可西里 更新时间:2023-11-01 17:08:23 25 4
gpt4 key购买 nike

我正在尝试通过 http 将我的 java 客户端应用程序连接到 ActiveMQ,但不断收到错误:(底部的完整错误)

javax.jms.JMSException: Could not post command: ProducerInfo 
No such field org.apache.activemq.command.ProducerInfo.sentCount

还有连接到ActiveMQ,因为服务端也报错:(完全报错在底部)

com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field 
org.apache.activemq.command.ProducerInfo.sentCount

库或 jar 有问题吗?

此连接有效,我连接的原因是:tcp://localhost:61616

activemq.xml

<broker>
...
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="http" uri="http://0.0.0.0:8081"/>
</transportConnectors>
...
</broker>

我的 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 客户端

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

任何人都可以帮助我启动并运行这个东西吗?

客户端错误:

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

服务器 Activity 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)

最佳答案

我猜你混合了不同的 ActiveMQ 版本/包,其中之一是 5.9.0(或之前)。 sentCount 字段从 5.9.1 版本开始存在。

  • 版本 5.9.0 于 2013 年 10 月 14 日发布
  • 字段 sentCount 添加于 2013 年 12 月 3 日

关于java - ActiveMQ http 连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30776187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com