How to create listner REST consumer in ActiveMQ

2019-07-29 14:37发布

问题:

I have created ActiveMQ consumer as follow in order consume queued item

but my problem is how can I keep checking on this queue since content publishing to this perticular queue can happen anytime but I can't keep listening to the queue since I'm using rest client GET method(HTTP) (NOT jms TCP connection), using infinite loop is no solution for me. Is there any out of the box solution for this other than custom solution within the ActiveMQ rest inteface

PropertyResourceBundle prop = CommonUtils.getInstance().getProperties();
String serverUrl = prop.getString("spring.activemq.server-url");
String userName = prop.getString("spring.activemq.user");
String password = prop.getString("spring.activemq.password");

String url = serverUrl + "/api/message?destination=queue:

RestClient client = new RestClient(userName, password);
String activeMQResponse = client.get(url);
System.out.println(activeMQResponse);