ActiveMQ学习笔记之四--启动嵌入式Broker(纯代码方式)

2019-07-13 00:51发布

启动嵌入式Broker(纯代码方式) Broker最小依赖的JAR包集合:

 
手动启动Broker        BrokerService broker = new BrokerService();        broker.addConnector("tcp://localhost:61616");        broker.setPersistent(false);        broker.setUseJmx(false); //启用JMX监控          //启用Advisory指定队列的消息监控        PolicyMap policy = new PolicyMap();        PolicyEntry entry = new PolicyEntry();        entry.setAdvisoryForConsumed(true);        policy.put(new ActiveMQQueue(">"), entry);        broker.setDestinationPolicy(policy);          broker.start();          while (true) {            Thread.sleep(100000);        }   附件:嵌入式Broker