Package io.micronaut.jms.listener
Class JMSListenerRegistry
java.lang.Object
io.micronaut.jms.listener.JMSListenerRegistry
Registry for all
JMSListener
s managed by Micronaut JMS. Listeners can be dynamically registered
using the register(Connection, JMSDestinationType, String, boolean, int, MessageListener, ExecutorService, boolean, Optional)
method. When the application context closes, all open connections, listeners, and sessions, are closed.- Since:
- 2.1.1
- Author:
- Elliott Pope
-
Constructor Summary
ConstructorDescriptionJMSListenerRegistry
(Collection<GlobalJMSListenerSuccessHandler> globalSuccessHandlers, Collection<GlobalJMSListenerErrorHandler> globalErrorHandlers) -
Method Summary
Modifier and TypeMethodDescriptionvoid
register
(JMSListener listener, boolean autoStart) Registers a new listener to be managed by Micronaut JMS.register
(javax.jms.Connection connection, JMSDestinationType destinationType, String destination, boolean transacted, int acknowledgeMode, javax.jms.MessageListener delegate, ExecutorService executor, boolean autoStart, Optional<String> messageSelector) Creates and registers a new listener to be managed by Micronaut JMS.void
shutdown()
Shuts down all registeredJMSListener
s.
-
Constructor Details
-
JMSListenerRegistry
public JMSListenerRegistry(Collection<GlobalJMSListenerSuccessHandler> globalSuccessHandlers, Collection<GlobalJMSListenerErrorHandler> globalErrorHandlers)
-
-
Method Details
-
register
Registers a new listener to be managed by Micronaut JMS.- Parameters:
listener
- - the listener to be registeredautoStart
- - whether the listener should be automatically started when registered- Throws:
javax.jms.JMSException
- - if the listener fails to start
-
register
public JMSListener register(javax.jms.Connection connection, JMSDestinationType destinationType, String destination, boolean transacted, int acknowledgeMode, javax.jms.MessageListener delegate, ExecutorService executor, boolean autoStart, Optional<String> messageSelector) throws javax.jms.JMSException Creates and registers a new listener to be managed by Micronaut JMS.- Parameters:
connection
- - theConnection
the listener will be linked todestinationType
- - theJMSDestinationType
of the target destinationdestination
- - the name of the target destinationtransacted
- - whether the listener should commit the transaction once the message is receivedacknowledgeMode
- - whether the message receipt should be acknowledgeddelegate
- - the underlying handler to delegate toexecutor
- - theExecutorService
to perform the message handling logic on.autoStart
- - whether the listener should be automatically started when registeredmessageSelector
- - the message selector for the listener- Returns:
- the listener that has been registered
- Throws:
javax.jms.JMSException
- - if the listener fails to start
-
shutdown
@PreDestroy public void shutdown()Shuts down all registeredJMSListener
s. If a listener fails to shut down then it is logged and skipped.
-