2013-03-12 2 views
1

JMS JMSTemplate 3.0.1RELEASE를 사용하여 JMS 메시지를 ActiveMQ 클러스터로 보냅니다.Spring JMSTemplate - 메시지 손실

비동기 요청을 보낼 수 있으려면 useAsynSend = true를 사용합니다. 모두 비상용 및 비회용입니다. 그러나 그들은 여전히 ​​끈질 기고, 나는 그들이 AMQ Kaha-DB에서 영속성을 유지하고 메시지 청취자에게 전달된다는 것을 확인할 수 있습니다. CorelationID 또는 JMSReplyTo가 없으므로 응답을 수신 대기하지 않습니다. ActiveMQProductBinding 클래스에서

<amq:connectionFactory id="amqJmsFactory" 
    brokerURL="failover:(tcp://MY-SERVER-01:61616,tcp://MY-SERVER-02:61616)?randomize=true&jms.useAsyncSend=true" /> 

<!-- JMS Producer Configuration --> 
<bean id="jmsProducerTemplate" class="org.springframework.jms.core.JmsTemplate" 
    p:connectionFactory-ref="amqJmsFactory" /> 

    <bean id="activeMQBinding" class="com.my.company.activemq.ActiveMQProductBinding"> 
    <property name="template" ref="jmsProducerTemplate" /> 
</bean> 

우리는 이제 로그 인쇄지고 로그에서 볼 수있는 다음과 같은 방법을

public void sendActiveMQMessageAsync(final Object message, String qName) { 
    log.info("About to send message"); 
    template.send(qName, new MessageCreator() { 
     public Message createMessage(Session session) throws JMSException { 
      ObjectMessage objectMessage = session.createObjectMessage((Serializable) message); 

      log.info("Sending message: " + objectMessage); 

      return objectMessage; 
     } 
    }); 
} 

있습니다. 예외는 발생하지 않습니다. 아직도 몇몇 메시지는 완전히 길을 잃고있다. 아마 ActiveMQ에 도달하지 않습니다. 위의 'qName'에 의해 정의 된 ActiveMQ 대기열의 메시지를 수신 대기하도록 구성된 Mule JMS Listener가 있습니다. 대부분의 메시지는 AMQ에 전달되고 Mule은 몇 초 이내에 메시지를 가져옵니다. 그러나 그것은 잃어 가고있는 일부 메시지 일뿐입니다. ActiveMQ에서 대기열을 검사했을 때 수신 된 모든 메시지가 Mule에 정상적으로 발송 된 것을 볼 수 있습니다. 따라서 메시지가 ActiveMQ에 전혀 도달하지 못하거나 AMQ가 거부하고있는 것으로 의심됩니다. 그러나 JMSTemplate 스프링 또는 ActiveMQ에 대한 로그가 없습니다.

작성된 메시지는 다음과 같습니다 (위의 방법으로 인쇄됩니다).

2013-03-11 16:33:11,752 INFO [com.my.company.activemq.ActiveMQProductBinding$1] Sending message: ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId = null, originalDestination = null, originalTransactionId = null, producerId = null, destination = null, transactionId = null, expiration = 0, timestamp = 0, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId = null, replyTo = null, persistent = false, type = null, priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = [email protected], marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = false, readOnlyBody = false, droppable = false} 

AMT에서 JMSTemplate 구성 또는 일부 동작에 누락 된 사항이 있습니까? 도와주세요!

도움 사람이 있습니까?

+0

누락 된 메시지는 다른 브로커에 있으며 소비되지 않는 것 같습니다. – techuser

+0

안녕하세요 .. 미안하지만 좀 더 정교하게 설명해 주실 수 있습니까? – Soumya

+0

제 제안은 장애 조치 연결을 사용하는 임의의 브로커에서 메시지 수를 확인하고 소비자가 실제로 브로커에서 소비하는지 확인하는 것입니다. – techuser

답변

1

2 생각할 수있는 이유. 1) 연결 팩토리가 잘못되었습니다. JMSTemplate과 함께 Pooled Connection Factory를 사용하여 메시지를 보내야합니다. org.apache.activemq.pool.PooledConnectionFactory

2) 우리는 useAsyncSend = true를 사용합니다. 즉, 보낸 사람이 메시지를 보내고 승인을 기다리지 않고 메시지가 손실 될 가능성이 있습니다. 이것은 가능성이 높지만 확실하지 않은 것 같습니다.

아직도 답변으로 받아들이지 않는 사람이 있으면 더 구체적으로 설명 할 수 있습니다. 그 동안에 누군가가이 질문에 비틀 거리면이 단서에 의해 도움을받을 수 있습니다.

관련 문제