2017-06-15 12 views
1

私のプロジェクトでは、同じ入力パラメータを持つ2つのインバウンドゲートウェイがありますが、応答は異なります。各ゲートウェイは異なるXMLで宣言されて呼び出されます。問題は、gateway1を呼び出すと、xml1の代わりにxml2に行くということです。 これをどのように処理する必要がありますか?私は別のシステムからゲートウェイを呼び出すXML2バネ統合 - 複数のゲートウェイ

<int:gateway id="invoke1" default-request-channel="requestChannel2" default-reply-channel="finalResult" 
        service-interface="<class name>" error-channel="errorChannel" default-reply-timeout="6000"/> 
     <int:channel id="errorChannel"/> 

でXML1

<int:gateway id="invoke" default-request-channel="requestChannel1" default-reply-channel="finalResult" 
       service-interface="<class name>" error-channel="errorChannel" default-reply-timeout="6000"/> 
    <int:channel id="errorChannel"/> 

で同じインターフェース

public interface MessageGateway { 
    @Gateway(requestChannel="requestChannel1") 
    @Payload("#args") 
    public Response1 invoke(Bean bean) throws Exception; 

    @Gateway(requestChannel="requestChannel2") 
    @Payload("#args") 
    public List<Response2> invoke2(Bean bean) throws Exception; 

} 

に2つのゲートウェイを有します。だから私はゲートウェイインターフェイスをオートワイヤーし、メソッドを呼び出します。ゲイリーさんのコメントを1として

オートワイヤリング

@Autowired 
private MessageGateway gateway; 
//calling 
gateway.invoke(bean); 
+0

両方のゲートウェイのためのあなたのオートワイヤリングを表示します。 –

+0

混乱を避けるために、異なるインタフェースにメソッドを配置する方が良いでしょう。この構成では、両方のゲートウェイに2つの方法があります。 –

+0

autowiringが失敗するはずです - あなたは2つのbean 'invoke'と' invoke1'を持っています。 Springはどのように自動配線のためのものを選択するか分からない。あなたはただ一つの ''か、別々のインタフェースにメソッドを置く必要があります。 –

答えて

1

ルックを追加します。同じインターフェイスに対して2つの<gateway>定義を必要としません。

@Gateway注釈または<gateway><method>サブ要素でそのプロパティを使用することができます。requestChannelが心配な場合は、そのプロパティを使用できます。

2つの場合は、2番目のものが勝っているように見えます。私たちはその設定の部分だけにプロキシを持っています。

+0

ありがとうございました。しかし、どのように私は正しいゲートウェイと関連するXMLを呼び出すことを確認します。 – Newbie

+0

ご不明な点がありましたら、 ''を1つ作成し、 '@ Gateway'メソッドごとに特定の' request-channel'を指定してください。 –

0

解決策は、メソッドのサブ要素を宣言することです。こちらのloadBrokerGateway:http://docs.spring.io/spring-integration/docs/2.0.0.RC1/reference/html/gateway.htmlも参照してください。

のでXML1

<int:gateway id="invoke" default-request-channel="requestChannel1" default-reply-channel="finalResult" service-interface="<class name>" error-channel="errorChannel" default-reply-timeout="6000"> 
    <int:method name="invoke" request-channel="requestChannel1" /> 
</int:gateway> 
<int:channel id="errorChannel"/> 

そしてXML2

<int:gateway id="invoke1" default-request-channel="requestChannel2" default-reply-channel="finalResult" service-interface="<class name>" error-channel="errorChannel" default-reply-timeout="6000"> 
    <int:method name="invoke" request-channel="requestChannel2" /> 
</int:gateway> 
<int:channel id="errorChannel"/> 
関連する問題