spring amqp 出站网关没有 output-channel 或 replyChannel header 可用

spring amqp outbound gateway no output-channel or replyChannel header available

面临将 Spring-AMQP 与 oubound-gateway 整合的困难..

错误: 原因:org.springframework.messaging.core.DestinationResolutionException:没有 output-channel 或 replyChannel header 可用

积分xml

<int:gateway id="outboundGateway" service-interface="com.amqp.outbound.gateway.OutboundGateway"     
                    default-reply-channel="defaultReplyChannel" >
    <int:method name="process"   request-channel="inboundRequestChannel"/>
</int:gateway>

<int:channel id="defaultReplyChannel"/>
<int:channel id="inboundRequestChannel"/>
<int:channel id="enrichedInboundRequestChannel"/>
<int:channel id="processAuthRequestChannel"/>

<int:chain input-channel="inboundRequestChannel" output-channel="enrichedInboundRequestChannel">
    <int:service-activator id="serviceActivator"
                   ref="ouboundService"  method="createRequest"/>
</int:chain>

<int-amqp:outbound-gateway id="outboundGtwyId" header-mapper="headerMapper"
                    request-channel="enrichedInboundRequestChannel"
                    reply-channel="defaultReplyChannel"
                    amqp-template="template" 
                    reply-timeout="30000"
                    exchange-name="request_exchange" 
                    routing-key="request_exchange_queue" />

<int-amqp:inbound-channel-adapter id="amqpMessageDriven"  queue-names="request_queue" 
                             connection-factory="rabbitConnectionFactory"  channel="processAuthRequestChannel"/>

<int:service-activator id="serviceActivator"
                   ref="ouboundService" input-channel="processAuthRequestChannel"
                   method="processRequest"/>

配置

@Bean
public RabbitTemplate template(ConnectionFactory rabbitConnectionFactory){
    final RabbitTemplate template = new RabbitTemplate(rabbitConnectionFactory);
    return template;
}


@Bean
public Binding binding(){
    return BindingBuilder.bind(this.queue()).to(this.exchange()).with("request_exchange_queue");
}

@Bean
public DirectExchange exchange(){
    return new DirectExchange("request_exchange");
}

@Bean
public Queue queue(){
    return new Queue("request_queue", true, false, true);
}

服务Class

@Service
public final class OuboundService {



    public Message createRequest(String message){
        System.out.println("Inside createRequest : "+ message);
        final Message builtMessage = MessageBuilder.withBody(message.getBytes())
                .setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN)
                .setCorrelationIdString("123456").build();
        return builtMessage;
    }


    public Message processRequest(Message message){
        System.out.println("Inside process Request : "+ message.getBody());
        final Message result = MessageBuilder.withBody("Successful".getBytes()).copyProperties(message.getMessageProperties())
                                .copyHeaders(message.getMessageProperties().getHeaders()).build();
        return result;
    }

}

有人可以帮忙解决这里遗漏的问题吗,为什么出站网关不产生回复?仅供参考 - 我是 AMQP 的新手。任何帮助将不胜感激。

您的问题不在出站网关上,而在 processRequest 服务激活器上。仅仅因为你在那里使用 <int-amqp:inbound-channel-adapter> 而这个肯定不会填充 replyChannel header - 它只是不期望任何回复。因此,尝试从上述服务激活器发送它失败并显示 DestinationResolutionException .

如果您真的打算从那里发送回复,请考虑改用 AMQP 入站网关。