diff --git a/src/docbkx/gateway.xml b/src/docbkx/gateway.xml index 8483e2b4cf..ece10d5dea 100644 --- a/src/docbkx/gateway.xml +++ b/src/docbkx/gateway.xml @@ -98,6 +98,35 @@ In the above case you can clearly see how a different header value will be set for the 'RESPONSE_TYPE' header based on the gateway's method. + + As with anything else, Gateway invocation might result in error. + By default all error that have occurred downstream will be re-thrown as MessagingExeption (RuntimeException) + upon Gateway's method invocation. However there are times when you may want to treat Exception as a valid reply, + by mapping it to a Message. To accomplish this Gateway provides support for Exception mappers via exception-mapper + attribute. + + + + + + ]]> + + foo.bar.SampleExceptionMapper is the implementation of + org.springframework.integration.message.InboundMessageMapper which only defines one method toMessage(Object object). +{ + public Message toMessage(Throwable object) throws Exception { + MessageHandlingException ex = (MessageHandlingException) object; + return MessageBuilder.withPayload("Error happened in message: " + + ex.getFailedMessage().getPayload()).build(); + } + +} + ]]> + + \ No newline at end of file diff --git a/src/docbkx/jms.xml b/src/docbkx/jms.xml index 97fd8373e4..ce53db987e 100644 --- a/src/docbkx/jms.xml +++ b/src/docbkx/jms.xml @@ -146,6 +146,35 @@ Integration Message payload will be converted into a JMS Message (e.g. String payload becomes a JMS TextMessage). + + As with anything else, Gateway invocation might result in error. + By default Producer will not be notified of the errors thta might have occurredon ythe consumer side and will time out waiting for + the reply. However there might be times when you to communicate error condition back to the consumer, + in other words treat the Exception as a valid reply valid reply by mapping it to a Message. To accomplish this + JMS Inbound Gateway provides support for Exception mappers via exception-mapper + attribute. + + + + + + + ]]> + + foo.bar.SampleExceptionMapper is the implementation of + org.springframework.integration.message.InboundMessageMapper which only defines one method toMessage(Object object). +{ + public Message toMessage(Throwable object) throws Exception { + MessageHandlingException ex = (MessageHandlingException) object; + return MessageBuilder.withPayload("Error happened in message: " + + ex.getFailedMessage().getPayload()).build(); + } + +} + ]]> +