All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.annotation.RabbitListener Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2014-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.core.MessageListener;
import io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter;
import io.bitsensor.plugins.shaded.org.springframework.messaging.handler.annotation.MessageMapping;

/**
 * Annotation that marks a method to be the target of a Rabbit message
 * listener on the specified {@link #queues()} (or {@link #bindings()}).
 * The {@link #containerFactory()}
 * identifies the {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory
 * RabbitListenerContainerFactory} to use to build the rabbit listener container. If not
 * set, a default container factory is assumed to be available with a bean
 * name of {@code rabbitListenerContainerFactory} unless an explicit default has been
 * provided through configuration.
 *
 * 

Processing of {@code @RabbitListener} annotations is performed by * registering a {@link RabbitListenerAnnotationBeanPostProcessor}. This can be * done manually or, more conveniently, through the {@code } * element or {@link EnableRabbit} annotation. * *

Annotated methods are allowed to have flexible signatures similar to what * {@link MessageMapping} provides, that is *

    *
  • {@link io.bitsensor.plugins.shaded.com.rabbitmq.client.Channel} to get access to the Channel
  • *
  • {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.core.Message} or one if subclass to get * access to the raw AMQP message
  • *
  • {@link io.bitsensor.plugins.shaded.org.springframework.messaging.Message} to use the messaging abstraction counterpart
  • *
  • {@link io.bitsensor.plugins.shaded.org.springframework.messaging.handler.annotation.Payload @Payload}-annotated method * arguments including the support of validation
  • *
  • {@link io.bitsensor.plugins.shaded.org.springframework.messaging.handler.annotation.Header @Header}-annotated method * arguments to extract a specific header value, including standard AMQP headers defined by * {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.support.AmqpHeaders AmqpHeaders}
  • *
  • {@link io.bitsensor.plugins.shaded.org.springframework.messaging.handler.annotation.Headers @Headers}-annotated * argument that must also be assignable to {@link java.util.Map} for getting access to all * headers.
  • *
  • {@link io.bitsensor.plugins.shaded.org.springframework.messaging.MessageHeaders MessageHeaders} arguments for * getting access to all headers.
  • *
  • {@link io.bitsensor.plugins.shaded.org.springframework.messaging.support.MessageHeaderAccessor MessageHeaderAccessor} * or {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.support.AmqpMessageHeaderAccessor AmqpMessageHeaderAccessor} * for convenient access to all method arguments.
  • *
* *

Annotated methods may have a non {@code void} return type. When they do, the result of the * method invocation is sent as a reply to the queue defined by the * {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.core.MessageProperties#getReplyTo() ReplyTo} header of the * incoming message. When this value is not set, a default queue can be provided by * adding @{@link io.bitsensor.plugins.shaded.org.springframework.messaging.handler.annotation.SendTo SendTo} to the method * declaration. * *

When {@link #bindings()} are provided, and the application context contains a * {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.core.RabbitAdmin}, * the queue, exchange and binding will be automatically declared. * *

When defined at the method level, a listener container is created for each method. The * {@link MessageListener} is a {@link MessagingMessageListenerAdapter}, configured with a * {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.listener.MethodRabbitListenerEndpoint}. * *

When defined at the class level, a single message listener container is used to service * all methods annotated with {@code @RabbitHandler}. Method signatures of such annotated * methods must not cause any ambiguity such that a single method can be resolved for a * particular inbound message. The {@link MessagingMessageListenerAdapter} is configured with * a {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.listener.MultiMethodRabbitListenerEndpoint}. * * @author Stephane Nicoll * @author Gary Russell * @since 1.4 * @see EnableRabbit * @see RabbitListenerAnnotationBeanPostProcessor * @see RabbitListeners */ @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE }) @Retention(RetentionPolicy.RUNTIME) @MessageMapping @Documented @Repeatable(RabbitListeners.class) public @interface RabbitListener { /** * The unique identifier of the container managing for this endpoint. *

If none is specified an auto-generated one is provided. * @return the {@code id} for the container managing for this endpoint. * @see io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry#getListenerContainer(String) */ String id() default ""; /** * The bean name of the {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory} * to use to create the message listener container responsible to serve this endpoint. *

If not specified, the default container factory is used, if any. * @return the {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory} * bean name. */ String containerFactory() default ""; /** * The queues for this listener. * The entries can be 'queue name', 'property-placeholder keys' or 'expressions'. * Expression must be resolved to the queue name or {@code Queue} object. * Mutually exclusive with {@link #bindings()} * @return the queue names or expressions (SpEL) to listen to from target * {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.listener.MessageListenerContainer}. */ String[] queues() default {}; /** * When {@code true}, a single consumer in the container will have exclusive use of the * {@link #queues()}, preventing other consumers from receiving messages from the * queues. When {@code true}, requires a concurrency of 1. Default {@code false}. * @return the {@code exclusive} boolean flag. */ boolean exclusive() default false; /** * The priority of this endpoint. Requires RabbitMQ 3.2 or higher. Does not change * the container priority by default. Larger numbers indicate higher priority, and * both positive and negative numbers can be used. * @return the priority for the endpoint. */ String priority() default ""; /** * Reference to a {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.core.RabbitAdmin * RabbitAdmin}. Required if the listener is using auto-delete * queues and those queues are configured for conditional declaration. This * is the admin that will (re)declare those queues when the container is * (re)started. See the reference documentation for more information. @return the {@link io.bitsensor.plugins.shaded.io.bitsensor.plugins.shaded.org.springframework.amqp.rabbit.core.RabbitAdmin} bean name. */ String admin() default ""; /** * Array of {@link QueueBinding}s providing the listener's queue names, together * with the exchange and optional binding information. * @return the bindings. * @since 1.5 */ QueueBinding[] bindings() default {}; /** * If provided, the listener container for this listener will be added to a bean * with this value as its name, of type {@code Collection}. * This allows, for example, iteration over the collection to start/stop a subset * of containers. * @return the bean name for the group. * @since 1.5 */ String group() default ""; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy