I have a problem with message driven EJB. I have too applications Web Service and EJB application which contains MessageDrivenBean.
To send message to JMS I'm using ObjectMessage: Here is my code:
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, 1);
MessageProducer messageProducer = session.createProducer(queue);
ObjectMessage outMessage = session.createObjectMessage();
outMessage.setObject(((Serializable) operation));
LOGGER.debug("Sending message...");
messageProducer.send(outMessage);
LOGGER.debug("Sending message: done.");
messageProducer.close();
session.close();
connection.close();
When I call my web service I am calling this method as well. The message arives at MDB and starts to process. Here is my MDB code:
@MessageDriven(mappedName = "jms/cbsDestination", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class OperationsBackgroundService implements MessageListener {
//Some code....
public void onMessage(Message message) {
LOGGER.debug("Got message: " + message.toString());
if (message instanceof ObjectMessage) {
ObjectMessage objectMessage = (ObjectMessage) message;
Operation operation = null;
}
Its all OK, I get the message, it starts to process and it ends as I expect.
But the problem is: When I send first message to MDB it starts process it (OK), then, when first message is processing I send second message to my MDB, and it starts processes it as well. Ass I know the JMS is characterized by that if I send one message and that one is processing, other messages waits until the first is processed. Or am I missing something here? Please help. Maybe there is some properties I forgot to set?
Thanks id advance.