AMQP: Async Gateway, Start Template

https://build.spring.io/browse/INT-MJATS41-884/

The gateway must start the template.
This commit is contained in:
Gary Russell
2017-01-21 09:51:44 -05:00
parent 6cf901896e
commit 2f7dfbde53
3 changed files with 15 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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.
@@ -58,6 +58,18 @@ public class AsyncAmqpOutboundGateway extends AbstractAmqpOutboundEndpoint {
return "amqp:outbound-async-gateway";
}
@Override
protected void doStart() {
super.doStart();
this.template.start();
}
@Override
protected void doStop() {
this.template.stop();
super.doStop();
}
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
org.springframework.amqp.core.Message amqpMessage = MappingUtils.mapMessage(requestMessage,

View File

@@ -98,7 +98,6 @@ public class AsyncAmqpGatewayTests {
AsyncRabbitTemplate asyncTemplate = new AsyncRabbitTemplate(template, container);
asyncTemplate.setEnableConfirms(true);
asyncTemplate.setMandatory(true);
asyncTemplate.start();
SimpleMessageListenerContainer receiver = new SimpleMessageListenerContainer(ccf);
receiver.setBeanName("receiver");
@@ -145,6 +144,7 @@ public class AsyncAmqpGatewayTests {
gateway.setRoutingKey("asyncQ1");
gateway.setBeanFactory(mock(BeanFactory.class));
gateway.afterPropertiesSet();
gateway.start();
Message<?> message = MessageBuilder.withPayload("foo").setErrorChannel(errorChannel).build();

View File

@@ -107,6 +107,7 @@ public class OutboundEndpointTests {
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());