Last active
August 29, 2015 14:14
-
-
Save rufer7/8686fcf28e5d4e10b552 to your computer and use it in GitHub Desktop.
Sample configuration for spring integration gateways to integrate with AMQP (Rabbitmq)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" | |
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/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"> | |
<!-- INFRASTRUCTURE --> | |
<rabbit:connection-factory id="connectionFactory" host="${amqp.host}" virtual-host="${amqp.virtualHost}" port="${amqp.port}" username="${amqp.user}" password="${amqp.password}"/> | |
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory"/> | |
<rabbit:admin connection-factory="connectionFactory"/> | |
<!-- LOGGING CHANNEL ADAPTER --> | |
<int:logging-channel-adapter id="loggingChannel" log-full-message="true" logger-name="tapInbound" level="INFO"/> | |
<!-- ERROR HANDLER --> | |
<bean id="sampleErrorHandler" class="be.rufer.amqp.integration.messaging.handler.error.SampleErrorHandler" /> | |
<!-- SAMPLE HEADER ENRICHER --> | |
<bean id="sampleHeaderEnricher" class="be.rufer.amqp.integration.messaging.enricher.SampleHeaderEnricher" /> | |
<!-- INCOMING --> | |
<rabbit:queue name="${incoming.queue}"/> | |
<rabbit:fanout-exchange name="${incoming.exchange}"> | |
<rabbit:bindings> | |
<rabbit:binding queue="${incoming.queue}"/> | |
</rabbit:bindings> | |
</rabbit:fanout-exchange> | |
<int:channel id="rawInputChannel"/> | |
<int-amqp:inbound-channel-adapter channel="rawInputChannel" | |
queue-names="${incoming.queue}" | |
connection-factory="connectionFactory" | |
error-handler="sampleErrorHandler" | |
mapped-request-headers="*"/> | |
<int:object-to-string-transformer input-channel="rawInputChannel" output-channel="stringifiedFromAMQP"/> | |
<int:publish-subscribe-channel id="stringifiedFromAMQP"> | |
<int:interceptors> | |
<int:wire-tap channel="loggingChannel"/> | |
</int:interceptors> | |
</int:publish-subscribe-channel> | |
<int:service-activator input-channel="stringifiedFromAMQP" ref="sampleMessageHandler"/> | |
<bean id="sampleMessageHandler" | |
class="be.rufer.amqp.integration.messaging.handler.SampleMessageHandler"/> | |
<!-- OUTGOING --> | |
<int:channel id="rawToAMQP"/> | |
<int:channel id="amqpRequestChannel"/> | |
<int:gateway id="sampleGateway" | |
service-interface="be.rufer.amqp.integration.messaging.gateway.SampleGateway" | |
default-request-channel="rawToAMQP"> | |
<int:method name="sendSomething"> | |
<int:header name="${another.custom.header.key}" value="${another.custom.header.value}"/> | |
</int:method> | |
</int:gateway> | |
<int:chain id="outgoingChain" | |
input-channel="rawToAMQP" | |
output-channel="amqpRequestChannel"> | |
<int:object-to-json-transformer/> | |
<int:header-enricher ref="sampleHeaderEnricher" | |
method="addCustomHeaders"/> | |
</int:chain> | |
<int-amqp:outbound-channel-adapter | |
id="amqp-request-channel" | |
channel="amqpRequestChannel" | |
exchange-name="${outgoing.exchange}" | |
mapped-request-headers="*"/> | |
<rabbit:fanout-exchange name="${outgoing.exchange}"/> | |
</beans> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment