首页 > 解决方案 > Apache Qpid JMS 客户端消息生产者卡住并且未传递到队列

问题描述

我正在尝试通过 AMQP 1.0 协议向 Qpid 代理发送消息。该队列已命名queue2,并且已在默认虚拟主机下创建。但是,producer.send(message)永远卡住了。相同的代码可用于连接到 Azure 服务总线。我正在使用 qpid-jms-client 0.58。生产者代码是:

Hashtable<String, String> hashtable = new Hashtable<>();
hashtable.put("connectionfactory.myFactoryLookup", protocol + "://" + url + "?amqp.idleTimeout=120000&amqp.traceFrames=true");
hashtable.put("queue.myQueueLookup", queueName);
hashtable.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");

Context context = new InitialContext(hashtable);

ConnectionFactory factory = (ConnectionFactory) context.lookup("myFactoryLookup");
queue = (Destination) context.lookup("myQueueLookup");

Connection connection = factory.createConnection(username, password);
connection.setExceptionListener(new AmqpConnectionFactory.MyExceptionListener());

connection.start();

Session session=connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

// session.createQueue("queue3");
Queue queue = new JmsQueue("queue2");
MessageProducer messageProducer = session.createProducer(queue);
TextMessage textMessage = session.createTextMessage("new message");
messageProducer.send(textMessage) 

我可以在 Qpid 代理仪表板上看到连接和会话已成功建立: Qpid 代理仪表板

生产时应用程序的线程转储

java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000078327c550> (a org.apache.qpid.jms.provider.ProgressiveProviderFuture)
    at java.lang.Object.wait(Object.java:502)
    at org.apache.qpid.jms.provider.ProgressiveProviderFuture.sync(ProgressiveProviderFuture.java:154)
    - locked <0x000000078327c550> (a org.apache.qpid.jms.provider.ProgressiveProviderFuture)
    at org.apache.qpid.jms.JmsConnection.send(JmsConnection.java:773)
    at org.apache.qpid.jms.JmsNoTxTransactionContext.send(JmsNoTxTransactionContext.java:37)
    at org.apache.qpid.jms.JmsSession.send(JmsSession.java:964)
    at org.apache.qpid.jms.JmsSession.send(JmsSession.java:843)
    at org.apache.qpid.jms.JmsMessageProducer.sendMessage(JmsMessageProducer.java:252)
    at org.apache.qpid.jms.JmsMessageProducer.send(JmsMessageProducer.java:182)

我试图运行这个给出相同结果的例子。

标签: jmsamqpqpid

解决方案


一般来说,如果客户端没有发送它是因为远程没有授予它这样做的信用。您可以使用协议跟踪功能调试客户端状态(只需设置 PN_TRACE_FRM=true 并运行客户端)。

可能您以某种方式错误地配置了 Broker-J,并且您创建的目标不允许发送任何消息,或者您发送的消息足够多,以至于超出了写入限制。您应该查阅配置指南并查看您已经设置的内容。


推荐阅读