activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Uttara <uttara.chev...@gmail.com>
Subject Re: Lost messages - Abnormal Behaviour of activeMQ
Date Tue, 15 Jul 2014 04:57:26 GMT
Hi Tim,
Thanks for your reply,We are using Individual acknowledgement.
Actually three threads run in the background for three customers.And from
the queue we read the message based on the customer id in the message . If
the intended thread receives the message it acknowledges it. We are also
logging once after the message is read before acknowledging it. In certain
scenarios the message is being read in other two customer threads but not
for the intended customer as we could see the log points before
acknowledging it. And then to my surprise,the message gets lost. PFB the
piece of code where we have applied acknowledging strategy.


	for(int count=0;count<10;count++){			
			Object receivedMessage = queueReceiver.receiveNoWait();
			if(receivedMessage instanceof TextMessage)
			{
			
				message = (TextMessage) receivedMessage; 
				
				try {
					objMsgVO = util.convertMessageToVO(message.getText());
				} catch (Throwable e) {
					logger.error("Invalid Json ticket data.Going to Acknowledge");
					message.acknowledge();
				}
				
				if(objMsgVO.getCustomerId()!=null){
				boolean flag=false;
				for(int i=0,j=0;i<ToolsIntegratorPoller.customerName.length;i++,j++){
				
if(objMsgVO.getCustomerId().equalsIgnoreCase(ToolsIntegratorPoller.customerName[i]))
					{
						flag=true;
					}
				}
				if(flag){
			
if(objMsgVO.getCustomerId().equalsIgnoreCase(mqInitContext.getProperty("CUSTOMER_NAME")))
				{	
					logger.info("received: " + message.getText());
					
					returnMassage = message.getText();
					
					messageList.add(returnMassage);
					message.acknowledge();
					
				}
				
				}
				else {
					message.acknowledge();
					logger.error("Message does not have a valid customer name or Customer
name is not present in the ticket data");

				}
			}
			}
			
			
		
			
		
		}



--
View this message in context: http://activemq.2283324.n4.nabble.com/Lost-messages-Abnormal-Behaviour-of-activeMQ-tp4683240p4683265.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message