ActiveMQ 5.15.3在web控制台中显示0 producerCount

ActiveMQ 5.15.3在web控制台中显示0 producerCount,activemq,Activemq,activemq web控制台中的生产者计数始终显示0,即使有生产者连接到代理。我不知道为什么 我的生产者代码如下所示 public boolean postMessage(List<? extends JMSMessageBean> messageList, String data, int messageCount) throws JMSException { String queueName = null; MessageProducer p

activemq web控制台中的生产者计数始终显示0,即使有生产者连接到代理。我不知道为什么

我的生产者代码如下所示

public boolean postMessage(List<? extends JMSMessageBean> messageList, String data, int messageCount)
        throws JMSException {
    String queueName = null;
    MessageProducer producer = null;
    Connection connection = null;
    Session session = null;
    try {
        connection = pooledConnectionFactory.createConnection();
        connection.setExceptionListener(this);
        connection.start();
        session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);

        int index = 0;
        for (JMSMessageBean message : messageList) {
            if (producer == null || !message.getQueueName().equals(queueName)) {
                queueName = message.getQueueName();
                producer = getQueueProducer(queueName, session);
            }

            Message _omessage = session.createObjectMessage(message);
            _omessage.setStringProperty("MESSAGE_INDEX", messageCount + ":" + index);
            _omessage.setIntProperty("RETRY_COUNT", 0);
            _omessage.setJMSType(message.getJmsType());
            if (data != null) {
                _omessage.setStringProperty("RAW_DATA", data);
            }
            producer.send(_omessage);
            index++;
        }

    } catch (JMSException e) {
        logger.error("Exception while creating connection to jms broker", e);

    } finally {
        try {
            if (null != session) {
                session.close();
            }
            if (null != connection) {
                connection.close();
            }
            if(null != producer) {
                producer.close();
            }
        } catch (JMSException e) {
            logger.error(e.getMessage(), e);
        }
    }

    return true;
}

public boolean postMessage(ListActiveMQ客户机通常使用他们称之为“动态生产者”(dynamic producers)——非事务性会话的每条消息的生产者。如果您了解JMS对象生命周期,您会发现几乎不需要在非事务性会话中保留生产者对象,这与使用者对象不同

查看JMX中的dynamicProducers列表,您会发现它们正在被创建。您还可以监视咨询主题以查看它们被创建和销毁


旁注:您在finally中的对象关闭顺序不正确。您应该以相反的顺序关闭对象--生产者、会话、连接。

如果我不使用PooledConnectionFactory,那么我可以看到producerCount为正值。但我需要使用PooledConnectionFactory API。有人能帮我吗,怎么办。。