0

게시자와 게시자가 시작됩니다. 이제는 소비자가 시작하고 문제는 메시지가 준비된 대기열에서 메시지가 다시 전달 된 채로 대기열로 이동한다는 것입니다 나는 내가 ACK가 아닌 소비자 재시작에 보낼 경우에만 재 전달 또는 시작으로 표시해야합니다입니다 원하는 avoid.So 할토끼 대기열에서 준비되지 않은 큐로 이동하는 토끼 mQ 메시지

구성 :

@Bean 
public org.springframework.amqp.rabbit.connection.Connection mqConnection() { 
    CloudFactory cloudFactory = new CloudFactory(); 
    Cloud cloud = cloudFactory.getCloud(); 
    return cloud.getServiceConnector("mqservicename", ConnectionFactory.class, 
      null).createConnection(); 
} 
@Bean 
public StatefulRetryOperationsInterceptor interceptor() { 
     return RetryInterceptorBuilder.stateful().retryOperations(retryTemplate()).recoverer(new RejectAndDontRequeueRecoverer()) 

      .build(); 
} 
@Bean 
public SimpleMessageListenerContainer listenerContainer() { 
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); 
    container.setMessageListener(new MessageListenerAdapter()); 
    container.setAdviceChain(new Advice[] { 
      interceptor() 
    }); 

    return container; 
} 



@Bean 
public RetryTemplate retryTemplate(){ 
    Map map=new HashMap<Class<? extends Throwable>, Boolean>(); 
    map.put(CustomException.class, true); 
    RetryTemplate retryTemplate=new RetryTemplate(); 
    retryTemplate.setRetryPolicy(new SimpleRetryPolicy(3,map)); 
    return retryTemplate; 
} 
+0

메시지를 확인하겠습니까? – cantSleepNow

+0

그래, 나 was.Gows 코멘트와 함께 나는 그것을 지키고 위의 구성으로 시도했다. 그러나 그것은 단지 1 번만 시도하고 3을 제공하지 않는다. – user

답변

0

것은 당신이 봄 AMQP 당신,를 사용하는 경우 이런 질문을 할 때 구성을 보여줘야합니다.

ack 모드를 MANUAL로 설정하면 사용자는 해당 문제를 해결해야합니다. the documentation을 읽으십시오. AUTO ackmode의 경우, 컨테이너는 리스너가 정상적으로 반환 될 때 메시지를 확인합니다.

+0

나는 코드에서 재전송의 논리를 변경함으로써이를 해결할 수 있었다. 그러나 문제는 지금이다. 소량의 데이터를 테스트 할 수는 있지만 대용량 데이터의 경우 예외가 발생합니다. – user

+0

org.springframework.amqp.rabbit.connection.CachingConnectionFactory - 채널 셧다운 : 채널 오류. 프로토콜 방법 : #method (reply-code = 406, reply-text = PRECONDITION_FAILED - 알 수없는 배달 태그 123, class-id = 60, method-id = 80) – user

+0

세부 정보를 추가하려면 3 번 기회 모든 실패 (메시지의 유효성 검사를 수행하는 일부 논리)에 대해 basicNack을 사용하고 true로 큐에 넣습니다. 마지막 실패시 basicknack을 사용하고 false로 큐에 넣습니다. 성공을 위해 basicAck를 사용하고 다시 큐잉합니다. 거짓으로. – user