start jmsListener on button click event

Hello all,

I would like to subscribe to a topic from an activeMQ broker on localhost on button click event. I found good examples for @jmsListener and when starting listener during application start, it is no problem to consume messages. I have attached the message consumer and configuration class to connect to activeMQ.

What I don’t know, is how to start the listener during runtime on click event of Button component. And moreover, how to stop listener on button click event again and how to handle listener on page reload (should be possible to stop an already started listener after page reload). Is there eventually a short example explaining the how-to available?

Thanks a lot in advance, any help is highly appreciated

Best regards, Michael
Consumer.java (403 Bytes)
myConfiguration.java (1.83 KB)