Class JMSListenerRegistry

java.lang.Object
io.micronaut.jms.listener.JMSListenerRegistry

@Singleton public class JMSListenerRegistry extends Object
Registry for all JMSListeners 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 Details

  • Method Details

    • register

      public void register(JMSListener listener, boolean autoStart) throws jakarta.jms.JMSException
      Registers a new listener to be managed by Micronaut JMS.
      Parameters:
      listener - - the listener to be registered
      autoStart - - whether the listener should be automatically started when registered
      Throws:
      jakarta.jms.JMSException - - if the listener fails to start
    • register

      public JMSListener register(jakarta.jms.Connection connection, JMSDestinationType destinationType, String destination, boolean transacted, int acknowledgeMode, jakarta.jms.MessageListener delegate, ExecutorService executor, boolean autoStart, Optional<String> messageSelector) throws jakarta.jms.JMSException
      Creates and registers a new listener to be managed by Micronaut JMS.
      Parameters:
      connection - - the Connection the listener will be linked to
      destinationType - - the JMSDestinationType of the target destination
      destination - - the name of the target destination
      transacted - - whether the listener should commit the transaction once the message is received
      acknowledgeMode - - whether the message receipt should be acknowledged
      delegate - - the underlying handler to delegate to
      executor - - the ExecutorService to perform the message handling logic on.
      autoStart - - whether the listener should be automatically started when registered
      messageSelector - - the message selector for the listener
      Returns:
      the listener that has been registered
      Throws:
      jakarta.jms.JMSException - - if the listener fails to start
    • shutdown

      @PreDestroy public void shutdown()
      Shuts down all registered JMSListeners. If a listener fails to shut down then it is logged and skipped.