@Bean public RabbitTemplate template() { RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory()); rabbitTemplate.setRoutingKey(queue().getName()); return rabbitTemplate; }
@Bean public RabbitTemplate rabbitTemplate() { RabbitTemplate template = new RabbitTemplate(connectionFactory()); //The routing key = name of the queue in default exchange. template.setRoutingKey("MyQueue"); // Queue name template.setQueue("MyQueue"); return template; }
@Bean public RabbitTemplate rabbitTemplate() { RabbitTemplate template = new RabbitTemplate(connectionFactory()); template.setRoutingKey(this.helloWorldQueueName); return template; }
@Bean public RabbitTemplate rabbitTemplate() { RabbitTemplate template = new RabbitTemplate(connectionFactory()); //The routing key is set to the name of the queue by the broker for the default exchange. template.setRoutingKey(this.helloWorldQueueName); //Where we will synchronously receive messages from template.setQueue(this.helloWorldQueueName); return template; }
@Bean public RabbitTemplate rabbitTemplate() { RabbitTemplate template = new RabbitTemplate(connectionFactory()); template.setRoutingKey(this.helloWorldQueueName); template.setQueue(this.helloWorldQueueName); return template; }
/** * Construct an instance using the provided arguments. "Direct replyTo" is used for * replies. * @param connectionFactory the connection factory. * @param exchange the default exchange to which requests will be sent. * @param routingKey the default routing key. * @since 2.0 */ public AsyncRabbitTemplate(ConnectionFactory connectionFactory, String exchange, String routingKey) { Assert.notNull(connectionFactory, "'connectionFactory' cannot be null"); Assert.notNull(routingKey, "'routingKey' cannot be null"); this.template = new RabbitTemplate(connectionFactory); this.template.setExchange(exchange == null ? "" : exchange); this.template.setRoutingKey(routingKey); this.container = null; this.replyAddress = null; this.directReplyToContainer = new DirectReplyToMessageListenerContainer(this.template.getConnectionFactory()); this.directReplyToContainer.setMessageListener(this); }
/** * Construct an instance using the provided arguments. "Direct replyTo" is used for * replies. * @param connectionFactory the connection factory. * @param exchange the default exchange to which requests will be sent. * @param routingKey the default routing key. * @since 2.0 */ public AsyncRabbitTemplate(ConnectionFactory connectionFactory, String exchange, String routingKey) { Assert.notNull(connectionFactory, "'connectionFactory' cannot be null"); Assert.notNull(routingKey, "'routingKey' cannot be null"); this.template = new RabbitTemplate(connectionFactory); this.template.setExchange(exchange == null ? "" : exchange); this.template.setRoutingKey(routingKey); this.container = null; this.replyAddress = null; this.directReplyToContainer = new DirectReplyToMessageListenerContainer(this.template.getConnectionFactory()); this.directReplyToContainer.setMessageListener(this); }
@Bean RabbitTemplate approvedClaimRabbitTemplate(ConnectionFactory connectionFactory, @Value("${io.fundrequest.azrael.queue.approved-claim}") final String queueName) { RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); rabbitTemplate.setRoutingKey(queueName); RetryTemplate retryTemplate = new RetryTemplate(); retryTemplate.setRetryPolicy(new SimpleRetryPolicy(5)); rabbitTemplate.setRetryTemplate(retryTemplate); rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter()); return rabbitTemplate; } }
this.template = new RabbitTemplate(connectionFactory); this.template.setExchange(exchange == null ? "" : exchange); this.template.setRoutingKey(routingKey); this.container = new SimpleMessageListenerContainer(connectionFactory); this.container.setQueueNames(replyQueue);
@Bean public RabbitTemplate template(ConnectionFactory connectionFactory) { RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); rabbitTemplate.setRoutingKey(requests().getName()); return rabbitTemplate; }
@Bean public RabbitTemplate templateForDirect(ConnectionFactory connectionFactory) { RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); rabbitTemplate.setRoutingKey(requests().getName()); return rabbitTemplate; }
@Bean public RabbitTemplate template() { RabbitTemplate rabbitTemplate = new RabbitTemplate(cf()); rabbitTemplate.setRoutingKey(TEST_QUEUE); rabbitTemplate.setDefaultReceiveQueue(TEST_QUEUE2); rabbitTemplate.setMessageConverter(jsonMessageConverter()); return rabbitTemplate; }
@Bean public RabbitTemplate template() { RabbitTemplate rabbitTemplate = new RabbitTemplate(cf()); rabbitTemplate.setRoutingKey(QUEUE); rabbitTemplate.setBeforePublishPostProcessors(m -> { this.beforeMppCalled = true; return m; }); rabbitTemplate.setAfterReceivePostProcessors(afterMPP()); return rabbitTemplate; }
/** * @return Rabbit template with incorrect fixed reply queue. */ @Bean public RabbitTemplate fixedReplyQRabbitTemplateWrongQueue() { RabbitTemplate template = new RabbitTemplate(rabbitConnectionFactory()); template.setExchange(ex().getName()); template.setRoutingKey("test"); template.setReplyAddress(requestQueue().getName()); return template; }
/** * @return Rabbit template with fixed reply queue and small timeout. */ @Bean public RabbitTemplate fixedReplyQRabbitTemplate() { RabbitTemplate template = new RabbitTemplate(rabbitConnectionFactory()); template.setExchange(ex().getName()); template.setRoutingKey("dlx.reply.test"); template.setReplyAddress(replyQueue().getName()); template.setReplyTimeout(1); return template; }
/** * @return Rabbit template with fixed reply queue. */ @Bean public RabbitTemplate fixedReplyQRabbitTemplate() { RabbitTemplate template = new RabbitTemplate(rabbitConnectionFactory()); template.setExchange(ex().getName()); template.setRoutingKey("test"); template.setReplyAddress(replyExchange().getName() + "/" + replyQueue().getName()); return template; }
/** * @return Rabbit template with fixed reply queue, no reply container, no receive timeout. */ @Bean public RabbitTemplate fixedReplyQRabbitTemplateNoReplyContainer() { RabbitTemplate template = new RabbitTemplate(rabbitConnectionFactory()); template.setExchange(ex().getName()); template.setRoutingKey("testNoContainer"); template.setReplyAddress(replyExchange().getName() + "/" + replyQueue().getName()); return template; }
@Test public void testReceiveAndReplyNonStandardCorrelationNotBytes() { this.template.setDefaultReceiveQueue(ROUTE); this.template.setRoutingKey(ROUTE); MessageProperties messageProperties = new MessageProperties(); messageProperties.getHeaders().put("baz", "bar"); Message message = new Message("foo".getBytes(), messageProperties); this.template.send(ROUTE, message); this.template.setCorrelationKey("baz"); boolean received = this.template.receiveAndReply( message1 -> new Message("fuz".getBytes(), new MessageProperties())); assertTrue(received); message = this.template.receive(); assertNotNull(message); assertEquals("bar", message.getMessageProperties().getHeaders().get("baz")); }
cachingConnectionFactory.setHost("localhost"); final RabbitTemplate template = createSendAndReceiveRabbitTemplate(cachingConnectionFactory); template.setRoutingKey(ROUTE); template.setDefaultReceiveQueue(ROUTE); ExecutorService executor = Executors.newFixedThreadPool(1);
cachingConnectionFactory.setHost("localhost"); final RabbitTemplate template = createSendAndReceiveRabbitTemplate(cachingConnectionFactory); template.setRoutingKey(ROUTE); template.setDefaultReceiveQueue(ROUTE); ExecutorService executor = Executors.newFixedThreadPool(1);