Here you go...
Client side...
Code:
<int-stream:stdin-channel-adapter id="consoleIn" channel="toRabbit" >
<int:poller fixed-delay="1000" max-messages-per-poll="1" />
</int-stream:stdin-channel-adapter>
<int:channel id="toRabbit" />
<int-amqp:outbound-channel-adapter channel="toRabbit"
amqp-template="amqpTemplate" exchange-name="si.test.exchange"
routing-key="si.test.binding"/>
<!-- Errors coming back -->
<int-amqp:inbound-channel-adapter channel="serverErrors"
queue-names="si.error.queue"
connection-factory="connectionFactory" />
<int:service-activator input-channel="serverErrors">
<int-groovy:script>
println "Exception on server:" + payload
</int-groovy:script>
</int:service-activator>
Server
Code:
<int-amqp:inbound-channel-adapter channel="fromRabbit"
queue-names="si.test.queue"
error-channel="errorChannel"
connection-factory="connectionFactory" />
<int:channel id="fromRabbit" />
<int:service-activator input-channel="fromRabbit" output-channel="consoleOut">
<int-groovy:script>
throw new RuntimeException("Some Exception Occurred")
</int-groovy:script>
</int:service-activator>
<int-stream:stdout-channel-adapter id="consoleOut" append-newline="true"/>
<!-- Error Handling (errorChannel defined on inbound adapter) -->
<int:service-activator input-channel="errorChannel" output-channel="errorToClient">
<int-groovy:script>
"eek:" + payload.cause.message
</int-groovy:script>
</int:service-activator>
<int:channel id="errorToClient" />
<int-amqp:outbound-channel-adapter channel="errorToClient"
amqp-template="amqpTemplate" exchange-name="si.test.exchange"
routing-key="si.error.binding"/>
And the result...
Code:
Exception on server:eek:Some Exception Occurred