在我的項目中,我將有兩個入口網關具有相同的輸入參數,但不同的響應。每個網關都在不同的xml中被聲明。問題是當我打電話給gateway1時,它轉到xml2而不是xml1。 我們應該如何處理這個問題。在同一個界面春季集成 - 多網關
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;
}
兩個網關在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"/>
在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"/>
我從另一個調用系統的網關。所以我自動調用網關接口並調用方法。
按照加里的評論添加自動裝配
@Autowired
private MessageGateway gateway;
//calling
gateway.invoke(bean);
表現你對兩個網關自動裝配。 –
將方法放在不同的接口中可能會更好,以避免混淆。通過這種配置,兩個網關都有兩種方法。 –
自動裝配應該失敗 - 你有兩個bean'invoke'和'invoke1'。春天不知道如何選擇自動佈線。你或者只需要一個' ',或者你應該把這些方法放在不同的接口上。 –