O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring a listener container

To receive the message asynchronously, the easiest way is to use an annotated listener endpoint. We will use the @RabbitListener annotation as a message listener endpoint. To create this listener endpoint, we have to configure a message listener container using the SimpleRabbitListenerContainerFactory class, which is an implementation of the RabbitListenerContainerFactory interface. The following code is used to configure SimpleRabbitListenerContainerFactory:

@Beanpublic SimpleRabbitListenerContainerFactory listenerContainer() {    SimpleRabbitListenerContainerFactory factory = new     SimpleRabbitListenerContainerFactory();    factory.setConnectionFactory(connectionFactory()); factory.setMaxConcurrentConsumers(5); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required