INTSAMPLES-132 AMQP Publisher Confirms/Returns
JIRA: https://jira.spring.io/browse/INTSAMPLES-132 Polishing - PR Comments
This commit is contained in:
committed by
Artem Bilan
parent
90d5ee9282
commit
28116776c2
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
|
||||
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
|
||||
xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration/amqp http://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<!-- From STDIN To RabbitMQ -->
|
||||
|
||||
<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-expression="payload.toLowerCase() == 'nack' ? 'badExchange' : 'si.test.exchange'"
|
||||
routing-key-expression="payload.toLowerCase() == 'fail' ? 'badKey' : 'si.test.binding'"
|
||||
confirm-correlation-expression="payload"
|
||||
confirm-ack-channel="good"
|
||||
confirm-nack-channel="errors"
|
||||
return-channel="returns" />
|
||||
|
||||
<!--Confirms are correlated with the entire payload; for rich objects, we might just use 'payload.invoiceId' -->
|
||||
|
||||
<int:transformer input-channel="good" output-channel="stdOut" expression="payload + ' sent ok'"/>
|
||||
|
||||
<int:transformer input-channel="errors" output-channel="stdErr" expression="payload + ' send failed (nack)'"/>
|
||||
|
||||
<int:transformer input-channel="returns" output-channel="stdErr" expression="payload + ' returned:' + headers['amqp_returnReplyText']"/>
|
||||
|
||||
<!-- From RabbitMQ To STDOUT -->
|
||||
|
||||
<int-amqp:inbound-channel-adapter channel="fromRabbit"
|
||||
queue-names="si.test.queue" connection-factory="connectionFactory" />
|
||||
|
||||
<int:channel id="fromRabbit">
|
||||
<int:interceptors>
|
||||
<int:wire-tap channel="loggingChannel" />
|
||||
</int:interceptors>
|
||||
</int:channel>
|
||||
|
||||
<int:transformer input-channel="fromRabbit" output-channel="stdOut" expression="'Received: ' + payload" />
|
||||
|
||||
<int-stream:stdout-channel-adapter id="stdOut"
|
||||
append-newline="true" />
|
||||
|
||||
<int-stream:stderr-channel-adapter id="stdErr"
|
||||
append-newline="true" />
|
||||
|
||||
<int:logging-channel-adapter id="loggingChannel" log-full-message="true" logger-name="tapInbound"
|
||||
level="INFO" />
|
||||
|
||||
<!-- Infrastructure -->
|
||||
|
||||
<rabbit:connection-factory id="connectionFactory" host="localhost" publisher-confirms="true" publisher-returns="true" />
|
||||
|
||||
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" mandatory="true" /> <!-- for nacks -->
|
||||
|
||||
<rabbit:admin connection-factory="connectionFactory" />
|
||||
|
||||
<rabbit:queue name="si.test.queue" />
|
||||
|
||||
<rabbit:direct-exchange name="si.test.exchange">
|
||||
<rabbit:bindings>
|
||||
<rabbit:binding queue="si.test.queue" key="si.test.binding" />
|
||||
</rabbit:bindings>
|
||||
</rabbit:direct-exchange>
|
||||
|
||||
</beans>
|
||||
@@ -34,10 +34,12 @@
|
||||
</int:interceptors>
|
||||
</int:channel>
|
||||
|
||||
<int-stream:stdout-channel-adapter id="consoleOut" channel="fromRabbit"
|
||||
<int:transformer input-channel="fromRabbit" output-channel="consoleOut" expression="'Received: ' + payload" />
|
||||
|
||||
<int-stream:stdout-channel-adapter id="consoleOut"
|
||||
append-newline="true" />
|
||||
|
||||
<int:logging-channel-adapter id="loggingChannel" log-full-message="true"
|
||||
<int:logging-channel-adapter id="loggingChannel" log-full-message="true" logger-name="tapInbound"
|
||||
level="INFO" />
|
||||
|
||||
<!-- Infrastructure -->
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
<level value="info" />
|
||||
</logger>
|
||||
|
||||
<logger name="tapInbound">
|
||||
<level value="info" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="warn" />
|
||||
|
||||
Reference in New Issue
Block a user