@Bean public AsyncRabbitTemplate asyncRabbitTemplate(ConnectionFactory rabbitConnectionFactory) { return new AsyncRabbitTemplate(rabbitConnectionFactory, "", "", "asyncReplies"); }
@Test public void testAsyncDelayExpression() { ConnectionFactory connectionFactory = mock(ConnectionFactory.class); AsyncRabbitTemplate amqpTemplate = spy(new AsyncRabbitTemplate(new RabbitTemplate(connectionFactory), new SimpleMessageListenerContainer(connectionFactory), "replyTo")); amqpTemplate.setTaskScheduler(mock(TaskScheduler.class)); AsyncAmqpOutboundGateway gateway = new AsyncAmqpOutboundGateway(amqpTemplate); willAnswer( invocation -> amqpTemplate.new RabbitMessageFuture("foo", invocation.getArgument(2))) .given(amqpTemplate).sendAndReceive(anyString(), anyString(), any(Message.class)); gateway.setExchangeName("foo"); gateway.setRoutingKey("bar"); gateway.setDelayExpressionString("42"); gateway.setBeanFactory(mock(BeanFactory.class)); gateway.setOutputChannel(new NullChannel()); gateway.afterPropertiesSet(); gateway.start(); ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class); gateway.handleMessage(new GenericMessage<>("foo")); verify(amqpTemplate).sendAndReceive(eq("foo"), eq("bar"), captor.capture()); assertThat(captor.getValue().getMessageProperties().getDelay(), equalTo(42)); }
@Bean public AsyncRabbitTemplate asyncTemplate(RabbitTemplate template, SimpleMessageListenerContainer container) { return new AsyncRabbitTemplate(template, container); }
@Bean public AsyncRabbitTemplate asyncDirectTemplate(RabbitTemplate templateForDirect) { return new AsyncRabbitTemplate(templateForDirect); }
@Bean public AsyncRabbitTemplate asyncRabbitTemplate(ConnectionFactory rabbitConnectionFactory) { return new AsyncRabbitTemplate(rabbitConnectionFactory, "", "", "asyncReplies"); }
container.afterPropertiesSet(); container.start(); AsyncRabbitTemplate asyncTemplate = new AsyncRabbitTemplate(template, container); asyncTemplate.setEnableConfirms(true); asyncTemplate.setMandatory(true);
@Bean public AsyncRabbitTemplate asyncTemplate() { return new AsyncRabbitTemplate(template()); }
@Bean public AsyncRabbitTemplate asyncTemplate() { return new AsyncRabbitTemplate(rabbitTemplate()); }