Code:
<rabbit:template id="amqpTemplateCore" connection-factory="connectionFactoryCore" />
<bean id="connectionFactoryCore" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject"><ref bean="rabbitConfiguration" /></property>
<property name="targetMethod"><value>connectionFactory</value></property>
</bean>
<int-amqp:outbound-gateway
request-channel="requestIn"
reply-channel="requestOut"
amqp-template="amqpTemplateCore"
exchange-name="CDS"
routing-key="keyA">
</int-amqp:outbound-gateway>
bean:
public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory =
new CachingConnectionFactory(host);
connectionFactory.setVirtualHost(virtualhost);
connectionFactory.setPort(port);
connectionFactory.setUsername(username);
connectionFactory.setPassword(password);
connectionFactory.setPublisherReturns(true);
connectionFactory.setPublisherConfirms(true);
return (ConnectionFactory)connectionFactory;
}
答案 0 :(得分:1)
An outbound-gateway
is for request/reply
scenario. When you send something to an external system and wait for reply from there.
If your logic is one-way, just to send and forget, consider to use <int-amqp:outbound-channel-adapter>
.