开发者

MDB onMessage does not begin until ejbTimeout ends. Shouldn't it start asynchronously?

We have a javax.ejb.TimedObject which queues messages to an MDB like so...

ctx = new InitialContext();
QueueConnectionFactory qCF = (QueueConnectionFactory) ctx
        .lookup("java:comp/env/jms/queueconnfactory");
Queue q = (Queue) ctx.lookup("java:comp/env/jms/qu开发者_开发知识库eue");
conn = qCF.createQueueConnection();
session = conn.createQueueSession(true,
        Session.AUTO_ACKNOWLEDGE);
QueueSender sender = session.createSender(q);
TextMessage txtMsg = session.createTextMessage();
txtMsg.setLongProperty(JobMonitorUtil.JOB_REFERENCE_ID, filingId);
txtMsg.setLongProperty(JobMonitorUtil.JOB_ID, jobId);
txtMsg.setLongProperty(JobMonitorUtil.JOB_RUN_SID, jobRunSId);
sender.send(txtMsg);
session.close();
conn.close();

When I debug this (on Weblogic 10.3.1.0) I step over the sender.sent(txtMsg) line and I expect my onMessage breakpoint to be hit almost instantaneously. It doesn't hit my breakpoint until I let the ejbTimeout run (actually when I step out of TimerImpl.timerExpired). The message queue is on the same server which generates the messages.

To me it seems odd.

  • Aren't MDB messages sent asyncronously?
  • Could this be a configuration problem or is this how it's supposed to work?


You created a transactional session. JMS messages are not sent out until transaction is committed (otherwise rollback wouldn't be possible -- message has reached the remote system already).

The transaction is committed when you call session.close().

Solution would be (for example) to create a non-transactional session:

session = conn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜