amqp:outbound-gateway throwing ReplyRequiredException

时间:2016-08-31 18:39:14

标签: spring-integration

  • I am using int-amqp:outbound-gateway to create a message in Rabbit. The message is published but my flow stops with ReplyRequiredException setPublisherReturns and setPublisherConfirms are set on the CachingConnectionFactory
  • when I set requires-reply to 'false' the thread is frozen and doesn't continue

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;
    }

1 个答案:

答案 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>.