[jboss-user] [JBoss Messaging] - about transaction and order
the.finder
do-not-reply at jboss.com
Thu May 7 07:13:49 EDT 2009
In my case, ineed to process message by order, so i create a Session Bean (Processor) to do that, the code is like following:
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public boolean process() throws BusinessException {
try {
Message message = poll();
if (message != null) {
handle(message);
return true;
}
} catch (Exception e) {
logger.error("error", e);
throw new BusinessException(e);
}
return false;
}
in the function poll(), i just create a MessageConsumer and call receive()。
in another job, call this session bean like this:
processor.open();
try {
while (processor.process())
;
} finally {
processor.close();
}
and in open() function, i create connection and session, and in close() function i close them.
In my test, we put 10 messages into the queue, and the 5th one will process failed.
I found several strange problems:
1ã€messages after the 5th one was processed
2ã€there are 2 messages left, one is the 5th
How to explain these?
And how to receive 1, 2, 3, 4, and then blocked.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4229368#4229368
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4229368
More information about the jboss-user
mailing list