Package io.micronaut.jms.annotations
Annotation Interface JMSListener
@Documented
@Retention(RUNTIME)
@Target(TYPE)
@Bean
@DefaultScope(io.micronaut.context.annotation.Context.class)
@MessageListener
public @interface JMSListener
Declares a class for post-processing. Annotated classes must contain at
least one method annotated with
Queue or Topic, otherwise an
IllegalStateException will be thrown.
Additionally, the value specified by the JMSProducer must correspond
to exactly one JMSConnectionFactory or an IllegalStateException
will be thrown.
Usage:
@JMSConnectionFactory("connectionFactoryOne")
public ConnectionFactory connectionFactoryOne() {
return new ActiveMqConnectionFactory("vm://localhost?broker.persist=false");
}
@JMSConnectionFactory("connectionFactoryTwo")
public ConnectionFactory connectionFactoryTwo() {
RMQConnectionFactory connectionFactory = new RMQConnectionFactory();
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
connectionFactory.setVirtualHost("/");
connectionFactory.setHost("localhost");
connectionFactory.setPort(5672);
return connectionFactory;
}
@JMSListener("connectionFactoryOne")
public static class ListenerOne {
@Queue("my-activemq-queue")
public void onMessage(String message) {
// do logic
}
}
@JMSListener("connectionFactoryTwo")
public static class ListenerTwo {
@Queue("my-rabbitmq-queue")
public void handle(Integer message) {
// do logic
}
}
- Since:
- 1.0.0
- Author:
- Elliott Pope
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionName of theConnectionFactorybean in the context to use to configure theJMSListener. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<? extends JMSListenerErrorHandler>[]Class<? extends JMSListenerSuccessHandler>[]
-
Element Details
-
value
String valueName of theConnectionFactorybean in the context to use to configure theJMSListener. The name must correspond to a bean annotated withJMSConnectionFactoryand the values must be the same.- Returns:
- the name of the
JMSConnectionFactoryto use.
-
-
-
successHandlers
Class<? extends JMSListenerSuccessHandler>[] successHandlers- Returns:
- the classes of the success handlers to be added. These handlers must be present as
Singletoninstances.
- Default:
- {}
-
errorHandlers
Class<? extends JMSListenerErrorHandler>[] errorHandlers- Returns:
- the classes of the error handlers to be added. These handlers must be present as
Singletoninstances.
- Default:
- {}
-