Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
373 views
in Technique[技术] by (71.8m points)

How to separate broker-url from its parameters (ActiveMQ Artemis + Spring Boot)

I have an application.yml file which contains a broker-url parameter

artemis:
  broker-url: "tcp://localhost:61616?consumerWindowSize=1048576&ha=true&retryInterval=100&retryIntervalMultiplier=1.5&maxRetryInterval=60000&reconnectAttempts=10000"

My question is how can I separate tcp://localhost:61616 part from ?consumerWindowSize=1048576&ha=true&retryInterval=100&retryIntervalMultiplier=1.5&maxRetryInterval=60000&reconnectAttempts=10000"

Update NO. 1 my project layoutenter image description here

Update NO. 2

So, what I was after was something like this

ActiveMQJMSConnectionFactory f =
 new ActiveMQJMSConnectionFactory(brokerUrl + ":" +brokerPort + brokerParams);

and that I have achieved by changing my application.yml like this

artemis:
  broker-url: "tcp://localhost"
  broker-port: "61616"
  broker-params: "?consumerWindowSize=1048576&ha=true&retryInterval=100"

NOTES: I'm using spring boot 2.4.0

And now I can call my jar artifact like this

   java myjar.jar --broker-params="?consumerWindowSize=1048576" --broker-port="1111" --broker-url="tcp://192.168.1.2"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...