user1568854
user1568854

Reputation: 37

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

Facing difficulties integrating Spring-AMQP with oubound-gateway..

Error: Caused by: org.springframework.messaging.core.DestinationResolutionException: no output-channel or replyChannel header available

Integration 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"/>

Config

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

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

}

Can someone help what is missing here, why outbound gateway is not producing reply? FYI - my new to AMQP. any help would be greatly appreciated.

Upvotes: 0

Views: 722

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121272

Your problem isn’t on the Outbound Gateway, but exactly is on the processRequest service activator. Just because you’re using there <int-amqp:inbound-channel-adapter> and this one definitely doesn’t populate replyChannel header - it just doesn’t expect any reply. So, an attempt to send it from the mentioned service activator fails with a DestinationResolutionException .

If you really intend to send a reply from there, consider to switch to the AMQP Inbound Gateway instead.

Upvotes: 1

Related Questions