2016-04-11 13 views
0

私はACK & NACKチャネルを設定しようとしていると のようなエラーを取得していますが確認-ACKと確認-NACKチャネルは

Below are the things which I tried: 

1. confirm-correlation-expression="#root" //no result found 

2. Changed the amqp template like below 

<rabbit:connection-factory id="connectionFactory" host="localhost" publisher-confirms="true" publisher-returns="true" /> 

    <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" mandatory="true" /> <!-- for nacks --> 

    <rabbit:admin connection-factory="connectionFactory" /> 


      /> 

The error was not there but the ack channel is not getting invoked. 

Can anyone help me on this? 
「一つだけ確認コールバックチャンネルを一度に設定することができ、」呼び出され得ていませんここで

MQの設定ここで

<rabbit:template id="nonTransactionalRabbitTemplate" 
        connection-factory="nonTransactionalConnectionFactory" 
        mandatory="true" 
        channel-transacted="false" 
        confirm-callback="confirmCallback" 
        return-call`enter code here`back="returnCallback" /> 
    <rabbit:connection-factory id="nonTransactionalConnectionFactory" 
           connection-factory="rabbitClientConnectionFactory" 
           publisher-confirms="true" 
           publisher-returns="true"/> 

    <rabbit:connection-factory id="nonTransactionalConnectionFactory" 
           connection-factory="rabbitClientConnectionFactory" 
           publisher-confirms="true" 
           publisher-returns="true"/> 


    <bean id="rabbitClientConnectionFactory" class="com.rabbitmq.client.ConnectionFactory" > 
     <property name="uri" value="${mq.uri}" /> 
     <property name="requestedHeartbeat" value="30" /> 
    </bean> 

は私のアウトバウンドアダプタです

<int-amqp:outbound-channel-adapter channel="abc" 
             routing-key="xyz" 
             amqp-template="amqpTemplate" 
             confirm-correlation-expression="payload" 
             confirm-ack-channel="successRespTransformChannel" 
             confirm-nack-channel="failureRespTransformChannel" 
             return-channel="failureRespTransformChannel" 
             mapped-request-headers="*" 
0123ここ

は、アダプタ内のテンプレートを使用している場合、あなたは

 confirm-callback="confirmCallback" 
    return-callback="returnCallback" /> 

独自のコールバックを設定してはいけません

<chain input-channel="successRespTransformChannel"> 
     <int:header-enricher> 
     <error-channel ref="failed-publishing" /> 
     </int:header-enricher> 
     <service-activator id="successResp" expression="@abc.addRequestTracking(payload.id,'success')"/> 

    </chain> 

答えて

0

アダプタが確認され、リターンの両方のためのコールバックとしての地位を設定し、私のサービスの活性化因子であります。既にコールバックを設定しているので、これは失敗します。

<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" mandatory="true" /> <!-- for nacks --> 

mandatoryは返品を認めており、返品はできません。

EDIT

私はあなたが間違って何をしているかわかりません。私はちょうど...

@SpringBootApplication 
@ImportResource("context.xml") 
public class So36546646Application { 

    public static void main(String[] args) throws Exception { 
     ConfigurableApplicationContext ctx = SpringApplication.run(So36546646Application.class, args); 
     ctx.getBean("out", MessageChannel.class).send(new GenericMessage<>("foo")); 
     boolean received = ctx.getBean(MyService.class).latch.await(10, TimeUnit.SECONDS); 
     if (!received) { 
      System.err.println("Did not receive ack"); 
     } 
     ctx.getBean(RabbitAdmin.class).deleteQueue(ctx.getBean(Queue.class).getName()); 
     ctx.close(); 
    } 

    public static class MyService { 

     private final CountDownLatch latch = new CountDownLatch(1); 

     public void handle(Message<?> ack) { 
      System.out.println("ack:" + ack); 
      latch.countDown(); 
     } 
    } 

} 

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:rabbit="http://www.springframework.org/schema/rabbit" 
    xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp" 
    xmlns:int="http://www.springframework.org/schema/integration" 
    xsi:schemaLocation="http://www.springframework.org/schema/integration/amqp http://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd 
     http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd"> 

    <rabbit:connection-factory id="cf" publisher-confirms="true" publisher-returns="true" host="localhost" /> 

    <rabbit:template id="t" connection-factory="cf" mandatory="true" /> 

    <rabbit:admin connection-factory="cf" /> 

    <rabbit:queue id="anon" /> 

    <int:channel id="out" /> 

    <int-amqp:outbound-channel-adapter 
     channel="out" 
     amqp-template="t" 
     routing-key="#{anon.name}" 
     confirm-correlation-expression="payload" 
     confirm-ack-channel="acks" 
     confirm-nack-channel="acks" 
     return-channel="returns" /> 

    <int:service-activator input-channel="acks" ref="service" /> 

    <bean id="service" class="com.example.So36546646Application$MyService" /> 

    <int:channel id="returns"> 
     <int:queue /> 
    </int:channel> 

</beans> 

を簡単なテストケースを書いて、それがうまく働いた:

ack:GenericMessage [payload=foo, headers={amqp_publishConfirm=true, id=5eed89bf-11b6-76a5-34ed-0091c6bac2c8, timestamp=1460464254229}] 
+0

おかげゲイリーは、私は、コールバックを削除しても、パブリッシュ設定しています-confirms = true。それでも私のackチャンネルは呼び出されていません。あなたは私を助けてくれますか? – user3668349

+0

私の編集を参照してください。 DEBUGロギングで私とあなたのものを実行し、ログを比較してみてください。 –

関連する問題