-
1. Re: How to order a message to queue
gaohoward Apr 20, 2014 10:36 PM (in response to ravi.teja)I think you need to limit your TestQueue consumers to only one.
-
2. Re: How to order a message to queue
ravi.teja Apr 21, 2014 1:04 AM (in response to gaohoward)Hi Yong Hao Gao ,
Thank you for reply. But , I don't have any idea about to limit the TestQueue and how it works..?Could you please help me out
-
3. Re: How to order a message to queue
gaohoward Apr 21, 2014 3:10 AM (in response to ravi.teja)Do you have some code showing how you receive and process messages from testQueue?
Howard
-
4. Re: How to order a message to queue
ravi.teja Apr 21, 2014 3:36 AM (in response to gaohoward)package com.vmchannel.listener;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.inject.Inject;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import org.jboss.ejb3.annotation.ResourceAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.common.exception.ApplicationException;
import com.common.utils.ApplicationConstants;
import com.common.utils.JsonUtils;
import com.communication.destination.Queues;
import com.communication.message.ComponentMessage;
import com.communication.message.IdentificationDetail;
import com.communication.message.content.VoiceMessage;
import com.vmchannel.model.IVMChannelModel;
/**
* Message-Driven Bean implementation class for: VoiceMessageListener
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName="messageSelector", propertyValue="MESSAGE_TYPE='VoiceMessage'"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = Queues.VOICEMESSAGE_QUEUE), })
@ResourceAdapter("hornetq-ra.rar")
public class VMChannelListener implements MessageListener {
private @Inject IVMChannelModel vmChannelModel;
/**
* Logger for this class
*/
private Logger logger = LoggerFactory.getLogger(VMChannelListener.class);
/**
* Default constructor.
*/
public VMChannelListener() {
// TODO Auto-generated constructor stub
}
/**
* @see MessageListener#onMessage(Message)
*/
@SuppressWarnings("unchecked")
public void onMessage(Message message) {
logger.info("VoiceMailListener onMessage(Message message) - START");
try {
ObjectMessage objectMessage = (ObjectMessage) message;
ComponentMessage<VoiceMessage> componentMessage =(ComponentMessage<VoiceMessage>) objectMessage.getObject();
logger.info("VoiceMessage Recieved : \n {} ",JsonUtils.toJson(componentMessage));
if (!(componentMessage==null)) {
VoiceMessage voiceMessage = componentMessage
.getMessageContent();
IdentificationDetail identificationDetail = componentMessage
.getIdentificationDetails();
if (!(voiceMessage == null) && !(identificationDetail == null)) {
vmChannelModel.processVoiceMessage(identificationDetail,
voiceMessage);
} else {
// VoiceMessage | IdentificationDetail Object is required to process
throw new ApplicationException(
ApplicationConstants.ES_VM_01);
}
}
else{
//ComponentMessage is null
throw new ApplicationException(
ApplicationConstants.ES_VM_01);
}
} catch (Exception e) {
logger.error("VoiceMailListener onMessage(Message message)",e);
}
}
}
-
5. Re: How to order a message to queue
ravi.teja Apr 21, 2014 5:00 AM (in response to ravi.teja)Hi Yong Hao Gao ,
Please assume that there are multiple instance more than 2 like 4 jboss server instances and 2 hornetq servers.
-
6. Re: How to order a message to queue
gaohoward Apr 21, 2014 8:04 AM (in response to ravi.teja)Can you try adding:
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1"),
and see if it works?
I'm thinking if you need strict ordering you may want to have a look at 'message-group' feature with HornetQ. There are two examples for this. However because your use-case involves dirvert, you need to reconsider your design to adapt this feature. Maybe you can add a 'transformer' to the divert that using this feature.
Howard
-
7. Re: How to order a message to queue
clebert.suconic Apr 21, 2014 9:31 AM (in response to gaohoward)the MDB layer on the Resource Adapter will instantiate several consumers to process your message in parallel.
You could either set the maxSession=1 as Howard pointed out, or keep using multiple sessions but also use Message Grouping (look on the manual for message grouping).
However since you're using Topics, I guess it makes more session to just use maxSession=1. I'm just pointing out a bit more information for you.. but I think Howard (aka Yong Hao) has answered your question already.