0

usually, we add NetworkConnectors configuration in activemq.xml before we start the activemq service as below:

<networkConnectors>
      <networkConnector uri="static:(tcp://localhost:62001)"/>
 </networkConnectors>

but this time, i just used spring boot with activemq embeded. and i want to configure more networkConnectors danymiclly when the mq running. so i could not choose to add these in activemq.xml. but need to configure with java code in spring boot. i don't know how to implement this.

shilovk
  • 11,718
  • 17
  • 75
  • 74
tim_zhu
  • 1
  • 2

1 Answers1

0

you define the broker bean and add what you want as you do in xml

@Bean
public BrokerService broker() throws Exception {
    BrokerService broker = new BrokerService();
    broker.addConnector("tcp://localhost:5671");
    broker.addNetworkConnector("static:(tcp://localhost:62001)");
    return broker;
}
Hassen Bennour
  • 3,885
  • 2
  • 12
  • 20
  • thank you.i have another question. if i still need to download activemq package from activeMQ website and unzip and click activemq.bat to run it after i imported spring-boot-starter-activemq dependency. i found when i create a BrokerService with java code not in xml. and also run activemq.bat, i report error and service can not up. But when i stop and close activemq.bat,it work well. so i wondered when i imported spring-boot-starter-activemq dependency, i no need to download activeMQ zip package from website and install on my computer again – tim_zhu May 28 '18 at 07:14
  • nope, with bean broker() you create a full embedded AMQ broker, not need external one – Hassen Bennour May 28 '18 at 07:21