2017-08-04 7 views
1

複数のjpa:inbound-channel-adapterを使用しようとしています。しかし、私は問題があります。 2つのインバウンドチャネルアダプターを追加すると、最後のアダプターのみが動作します。たとえば、今はxとyと呼ばれる2つのインバウンドチャネルがあります。最初にxとyをapplication.xmlファイルに書き込むと、yだけが動作します。最初にyを書くと、xのみxが働きます。ここで、XML構成、Spring jpa:インバウンドチャネルアダプタの設定

<int:channel id="emailChannel" /> 
<int-jpa:inbound-channel-adapter 
    channel="emailChannel" entity-manager-factory="entityManagerFactory" 
    auto-startup="true" 
    jpa-query="select slt from Email slt where slt.mailStatus = 'NEW'" 
    expect-single-result="false" delete-after-poll="false"> 
    <int:poller fixed-rate="10000" > 
     <int:transactional propagation="REQUIRED" 
      transaction-manager="transactionManager" /> 
    </int:poller> 
</int-jpa:inbound-channel-adapter> 
<int:service-activator input-channel="emailChannel" ref="EmailSenderEndPoint" method="sendEmail" /> 


<int:channel id="msgChannel" /> 
<int-jpa:inbound-channel-adapter 
    channel="msgChannel" entity-manager-factory="entityManagerFactory" 
    auto-startup="true" 
    jpa-query="select rm from Msg rm where rm.isApproved= '1' " 
    expect-single-result="false" delete-after-poll="false"> 
    <int:poller fixed-rate="30000"> 
     <int:transactional propagation="REQUIRED" 
      transaction-manager="transactionManager" /> 
    </int:poller> 
</int-jpa:inbound-channel-adapter> 
<int:service-activator input-channel="msgChannel" ref="MsgSenderEndPoint" method="sendMsg" /> 

は、上記の例であり、唯一msgChannel作品。しかし、以下のように変更すると、emailChannelだけが動作します。

<int:channel id="msgChannel" /> 
<int-jpa:inbound-channel-adapter 
    channel="msgChannel" entity-manager-factory="entityManagerFactory" 
    auto-startup="true" 
    jpa-query="select rm from Msg rm where rm.isApproved= '1' " 
    expect-single-result="false" delete-after-poll="false"> 
    <int:poller fixed-rate="30000"> 
     <int:transactional propagation="REQUIRED" 
      transaction-manager="transactionManager" /> 
    </int:poller> 
</int-jpa:inbound-channel-adapter> 
<int:service-activator input-channel="msgChannel" ref="MsgSenderEndPoint" method="sendMsg" /> 


<int:channel id="emailChannel" /> 
<int-jpa:inbound-channel-adapter 
    channel="emailChannel" entity-manager-factory="entityManagerFactory" 
    auto-startup="true" 
    jpa-query="select slt from Email slt where slt.mailStatus = 'NEW'" 
    expect-single-result="false" delete-after-poll="false"> 
    <int:poller fixed-rate="10000" > 
     <int:transactional propagation="REQUIRED" 
      transaction-manager="transactionManager" /> 
    </int:poller> 
</int-jpa:inbound-channel-adapter> 
<int:service-activator input-channel="emailChannel" ref="EmailSenderEndPoint" method="sendEmail" /> 

問題が何かを理解できません。私たちを手伝ってくれますか?

編集:問題を解決しました。私はサービスアクチベータクラスにインターフェイスを追加し、問題は解決しました。

+0

Spring Integrationバージョンとは何ですか? –

答えて

0

OK。これはバグです。 JIRA:https://jira.spring.io/browse/INT-4325を参照してください。

だから、あなたの問題を解決し、あなたはそれらの<int-jpa:inbound-channel-adapter>の定義のためのユニークなidを定義する必要があります。

<int-jpa:inbound-channel-adapter id="msgJpaAdapter" 
channel="msgChannel" entity-manager-factory="entityManagerFactory" 

... 

<int-jpa:inbound-channel-adapter id="emailJpaAdapter" 
channel="emailChannel" entity-manager-factory="entityManagerFactory" 

UPDATE

我々は設定のためのテストケースがあります。

<int-jpa:inbound-channel-adapter id="jpaInboundChannelAdapter1" 
     entity-manager-factory="entityManagerFactory" 
     entity-class="org.springframework.integration.jpa.test.entity.StudentDomain" 
     expect-single-result="true" 
     parameter-source="jpaParameterSource" 
     channel="out"> 
    <int:poller fixed-rate="5000"/> 
</int-jpa:inbound-channel-adapter> 

<int-jpa:inbound-channel-adapter id="jpaInboundChannelAdapter2" 
    entity-manager-factory="entityManagerFactory" 
    entity-class="org.springframework.integration.jpa.test.entity.StudentDomain" 
    max-results="13" 
    delete-after-poll="true" 
    flush-after-delete="true" 
    channel="out"> 
    <int:poller fixed-rate="5000"/> 
</int-jpa:inbound-channel-adapter> 

などを:

JpaExecutor jpaExecutor1 = context.getBean("jpaInboundChannelAdapter1.jpaExecutor", JpaExecutor.class); 
    JpaExecutor jpaExecutor2 = context.getBean("jpaInboundChannelAdapter2.jpaExecutor", JpaExecutor.class); 
    assertNotNull(jpaExecutor1); 
    assertNotNull(jpaExecutor2); 

    assertNotSame(jpaExecutor1, jpaExecutor2); 

ただし、空の場合はidですが、実際には同じオブジェクトです。

+0

私はidを定義しましたが、それは私を助けませんでした。私が見つけた解決策は、サービスアクチベータの参照クラスへのインタフェースを追加することでした。 – Zapateus

+0

異なるチャネルアダプタ定義に対して異なるIDを使用していますか? –

+0

私の答えでUPDATEを見てください。 –

関連する問題