@Documented
@Retention(value=RUNTIME)
@Target(value=TYPE)
@Bean
@DefaultScope(value=io.micronaut.context.annotation.Context.class)
@MessageListener
public @interface JMSListener
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 } }
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
value
Name of the
ConnectionFactory bean in the context to
use to configure the JMSListenerContainer . |
public abstract java.lang.String value
ConnectionFactory
bean in the context to
use to configure the JMSListenerContainer
.
The name must correspond to a bean annotated with JMSConnectionFactory
and the values must be the same.JMSConnectionFactory
to use.