2017-10-29 15 views
0
ouboundゲートウェイと春AMQPを統合する困難に直面

..スプリング無し出力チャネル又はreplyChannelヘッダ利用可能

エラー:org.springframework.messaging.core.DestinationResolutionException:によって引き起こさ なし出力チャネル又は利用可能replyChannelヘッダ

統合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); 
} 

サービスクラス

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

} 

誰かが発信ゲートウェイが応答を生産されていない理由を、ここに欠けているものを助けることができますか? FYI - 私はAMQPを初めて利用しました。どんな助けでも大歓迎です。

答えて

1

問題はアウトバウンドゲートウェイにはありませんが、サービスアクティベータのprocessRequestにあります。ちょうどあなたがそこに<int-amqp:inbound-channel-adapter>を使用していると、この1つは間違いなくreplyChannelヘッダーを設定しません - それはすべての応答を期待していません。したがって、上記のサービスアクティベータからの送信は、DestinationResolutionExceptionで失敗します。

本当にそこから返信を送信する場合は、代わりにAMQP受信ゲートウェイに切り替えることを検討してください。

+0

返信ありがとうございます。別のスレッド(別のキューを持つ、jms-outboundゲートウェイのように、相関キーを使用してリクエスト/応答を関連付ける)のように、バインドされたゲートウェイに応答を送信する方法はありますか。この場合のprocessRequestの意味は、restcall(Async)を実行することによって外部システムに処理されます。彼らは再びアウトバウンドゲートウェイに応答するためにこのアプリへのポストコールを行います。 – user1568854

+0

これは可能です。しかし、それは全く異なる話であり、トピックの質問には関係しません。あなたは新しいSOスレッドを無料で作成できます。私たちはあなたに答えます。 –

+0

確かに、https://stackoverflow.com/questions/47016080/spring-amqp-outbound-gateway-to-produce-reply-from-a-different-theadlike-jms-ou – user1568854

関連する問題