Message driven bean creation
Hi,
In different tutorials I read that a message-driven bean which uses a Topic as destination, should exist before any message is send to this topic if it wants to receive this message.
However, if I use some print statements, I get the following:
PostMessage, before topicMessageProducer.send(message)
PostMessage, after topicMessageProducer.send(message)
TopicListener, constructor called!
TopicListener, postConstruct called!
TopicListener, onMessage called!
In which PostMessage is a servlet sending the message to the topic, and TopicListener is the message-driven bean. So this indicates, that my message is send between the first 2 prints, and only then, the message-driven bean is created, which still receives the message.
Can anybody clarify this?
Thanks!
Vaak
[844 byte] By [
vAaka] at [2007-11-27 7:10:29]

# 1
Hi Vaak,
All this output shows is that the message-bean *instance* is created lazily. That's a different issue
than when the message-bean itself is deployed and associated with the topic.The message-bean
container is free to wait until an actual message arrives before creating an instance of the bean.
However, the association to the topic is made when you deploy your application. As long as that
happens before the message is sent to the topic, the message-bean should receive it.
Note that there is also something in JMS called a "durable subscription".This is a way to give
queue-like behavior to each unique consumer of a topic. However, it is not the default and
would require some special configuration, so it's unlikely that's what's happening in your case.
--ken
ksaksa at 2007-7-12 19:02:00 >
