destinationSource.getQueues()没有返回正确的队列数

时间:2018-01-08 23:08:03

标签: java jms activemq

我想知道为什么下面的代码没有获取正确数量的队列。我的经纪人有25个队列,下面的代码总是只返回1个队列。

import java.util.Set;

import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.advisory.DestinationSource;
import org.apache.activemq.command.ActiveMQQueue;
public class Test {

    public static void main(String[] args) throws JMSException, InterruptedException {


         ConnectionFactory out = new ActiveMQConnectionFactory("tcp://localhost:61616");
          ActiveMQConnection connection = (ActiveMQConnection) out.createConnection();

          connection.start();
          Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
          DestinationSource ds = connection.getDestinationSource();
          Set<ActiveMQQueue> amqs = ds.getQueues();
          System.out.println("Number of Queues on Broker:"+amqs.size());
          session.close();
          connection.close();       
    }

ds.getQueues();尽管代理上有25个队列,但总是只返回1个队列。有没有办法使用这种方法获取正确数量的队列。

0 个答案:

没有答案