INT-4100: Improve RequestReplyExchanger

JIRA: https://jira.spring.io/browse/INT-4100

* Add `throws MessagingException` to the `RequestReplyExchanger` to make it fully messaging contract based
* Add test to the `ServiceActivatorDefaultFrameworkMethodTests` to demonstrate how many info is in the stack trace after `RequestReplyExchanger`
* Document how to be with the `throws` clause in custom gateways
* Fix `boolean` attributes in the `spring-integration-5.0.xsd`

* Fix `AbstractChannelAdapterParser` do not populate endpoint attributes if component is nested
* Fix typo in the `AmqpOutboundChannelAdapterParserTests`
* Increase timeouts in the  `MixedDispatcherConfigurationScenarioTests`

Reinstate `auto-startup` to none by default.
 Not all components expects `true` by default in their initial state

Also https://jira.spring.io/browse/INT-3432

Document the behavior of the `throws` clause on gateway method

Remove unrelated `bridge` id from the `<chain>`

Add What's new about  `RequestReplyExchanger` changes

Doc Polishing.
This commit is contained in:
Artem Bilan
2017-03-02 15:31:45 -05:00
committed by Gary Russell
parent 10ce68d3e3
commit 8da89c7cce
9 changed files with 126 additions and 35 deletions

View File

@@ -326,10 +326,10 @@ public class MixedDispatcherConfigurationScenarioTests {
executor.execute(messageSenderTask);
}
start.countDown();
assertTrue(allDone.await(5, TimeUnit.SECONDS));
assertTrue(allDone.await(10, TimeUnit.SECONDS));
executor.shutdown();
executor.awaitTermination(5, TimeUnit.SECONDS);
executor.awaitTermination(10, TimeUnit.SECONDS);
assertTrue("not all messages were accepted", failed.get());
verify(handlerA, times(14)).handleMessage(message);

View File

@@ -42,9 +42,9 @@
<gateway id="gateway" default-request-channel="requestChannel" default-reply-channel="replyChannel"/>
<channel id="requestChannel"/>
<bridge id="bridge" input-channel="requestChannel" output-channel="replyChannel"/>
<chain input-channel="requestChannel" output-channel="replyChannel">
<transformer expression="payload == 'foo' ? T(org.springframework.integration.handler.ServiceActivatorDefaultFrameworkMethodTests).throwIllegalStateException('Wrong payload') : payload"/>
</chain>
<channel id="replyChannel">
<queue/>

View File

@@ -16,6 +16,7 @@
package org.springframework.integration.handler;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
@@ -41,10 +42,12 @@ import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.transformer.MessageTransformationException;
import org.springframework.integration.util.StackTraceUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.ErrorMessage;
@@ -59,6 +62,7 @@ import org.springframework.util.concurrent.SettableListenableFuture;
* @author Mark Fisher
* @author Artem Bilan
* @author Gary Russell
*
* @since 2.0.1
*/
@ContextConfiguration
@@ -107,8 +111,22 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build();
this.gatewayTestInputChannel.send(message);
Message<?> reply = replyChannel.receive(0);
assertEquals("gatewayTestInputChannel,gatewayTestService,gateway,requestChannel,bridge,replyChannel",
assertEquals("gatewayTestInputChannel,gatewayTestService,gateway,requestChannel,replyChannel",
reply.getHeaders().get("history").toString());
message = MessageBuilder.withPayload("foo").setReplyChannel(replyChannel).build();
try {
this.gatewayTestInputChannel.send(message);
fail("Exception expected");
}
catch (Exception e) {
assertThat(e, instanceOf(MessageHandlingException.class));
assertThat(e.getCause(), instanceOf(MessageTransformationException.class));
assertThat(e.getCause().getCause(), instanceOf(MessageHandlingException.class));
assertThat(e.getCause().getCause().getCause(), instanceOf(java.lang.IllegalStateException.class));
assertThat(e.getMessage(), containsString("Expression evaluation failed"));
assertThat(e.getMessage(), containsString("Wrong payload"));
}
}
@Test
@@ -258,6 +276,10 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
assertEquals("test", ((MessagingException) error.getPayload()).getFailedMessage().getPayload());
}
public static void throwIllegalStateException(String message) {
throw new IllegalStateException(message);
}
@SuppressWarnings("unused")
private static class TestReplyingMessageHandler extends AbstractReplyProducingMessageHandler {