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

Creating a RabbitTemplate

Spring AMQP’s RabbitTemplate provides everything for the basic AMQP operations. The following code creates an instance of RabbitTemplate using connectionFactory:

@Beanpublic RabbitTemplate rabbitTemplate() {    RabbitTemplate template = new RabbitTemplate(connectionFactory());    template.setRoutingKey(ROUTING_KEY);    template.setExchange(RABBIT_MESSAGE_EXCHANGE);    template.setMessageConverter(messageConverter());    return template;}

RabbitTemplate acts as a helper class for the producer to send, and the consumer to receive, the messages.

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