• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MDB onMessage() not firing....Help needed please!

 
clement valentine
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
Iam testing a simple application using MDB in Weblogic 8.1 but the onMessage() method never gets triggered when messages arrive on the queue!.
This is the gist of things : A session bean writes to the queue and an MDB should receive the message and do a database insert by calling the create method on a CMP.

These are my descriptors:

<ejb-jar>.xml
---------------------------------------------------------
.....
<message-driven>
<display-name>CustomerMDB</display-name>
<ejb-name>CustomerMDB</ejb-name>
<ejb-class>autofactory.CustomerMDBBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
</message-driven>
.......
-------------------------------------------------------------
weblogic-ejb-jar.xml

<weblogic-enterprise-bean>
<ejb-name>CustomerMDB</ejb-name>
<message-driven-descriptor>
<pool>
<max-beans-in-free-pool>20</max-beans-in-free-pool>
<initial-beans-in-free-pool>5</initial-beans-in-free-pool>
</pool>
<destination-jndi-name>queue/Autoshop</destination-jndi-name> ;
</message-driven-descriptor>
</weblogic-enterprise-bean>

-------------------------------------------------------------------

This is a portion of my config.xml for the weblogic server showing the JMS setup.

config.xml (weblogic)

<JMSConnectionFactory JNDIName="jms/Autoshop" Name="AutoshopFactory"
Targets="myserver" XAConnectionFactoryEnabled="true"/>
<JMSServer Name="JMSClemDEV" PagingStore="" Store="Ejb20Store" Targets="myserver">
<JMSTopic CreationTime="1105766985348" JNDIName="topic/Autoshop"
JNDINameReplicated="false" Name="TopicAutoshop"/>
<JMSQueue CreationTime="1105775501794"
ErrorDestination="ErrorQueue" ExpirationPolicy="Redirect"
JNDIName="queue/Autoshop" JNDINameReplicated="false" Name="QueueAutoshop"/>
<JMSQueue CreationTime="1106043185507" JNDIName="queue/ErrorQ"
JNDINameReplicated="false" Name="ErrorQueue"/>
</JMSServer>
<JMSFileStore Directory="ejb20filestore" Name="Ejb20Store"/>
------------------------------------------------------------------------------- ------------------


The queue that Iam writing to is "queue/Autoshop". The queue uses a persistent filestore and I can see that the file contains the messages. But when I check the console it show "MESSAGE_PENDING" = 0 and "MESSAGES" = 0!
I have some 'println' in onMessage(), but they never get printed!!..The MDB just doesn't listen to the destination!!!

Here is my onMessage() method:




Here is the code from the session bean that writes to the queue:




The QueueConnectionFactory is XA enabled..

Thanks guys,
CLement
 
Brian Tinnel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is causing the problem, but you don't want to have a qconnect.start() in your session bean. start() is used to cause the connection to start receiving messages from the queue and is not needed if you are putting messages on the queue. However, I doubt that it is causing the problem you are seeing.

The only other thing I can think of is to make sure that your transaction attributes are all appropriate. In your case, the session bean and message bean should probably be "Required".

Finally, are you sure that there isn't another client listening to the same queue.
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try to check the same through normal java application program instead of MDB. In general developer will get the problem related to network/lookup of Queue.
 
H Sivad
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Malli Raman:
Please try to check the same through normal java application program instead of MDB. In general developer will get the problem related to network/lookup of Queue.


Yes, agreed. Then, make sure that the queue listener in the app server is configured for the queue, and that the MDBs are associated with the connection listener.
 
Sreenivas Mangasandra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi CLement,

The code is quite ok. i feel u r setting in the Web App Server are not correctly configured. I mean the Queue Listeners, Queue Connection Factories and Queue for the JNDI. and right values in it. It can be a type mistake in the name or an extra space.

U could just write a normal code to test a MDB for onMessage by manually putting a message in the queue.

Srinu.
 
clement valentine
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
It worked when I set "transacted" to false.

Old ---> QueueSession qsession = qconnect.createQueueSession(true,0);
New ---> QueueSession qsession = qconnect.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);

Also I realised that Session.AUTO_ACKNOWLEDGE is 1 and not 0! For that matter I can't find out what the static value '0' is in the javax.jms.Session API. Does '0' mean NO_ACKNOWLEDGEMENT?

According to the WLS doc. when "transacted" the ackowledge value is ignored. But somehow this didn't seem to work. Can anyone explain that for me please?

Whats the effect of setting the "transacted" to false? Does it mean that a rollback is not possible if anything down the line fails?

Thanks guys,
Clement
[ January 19, 2005: Message edited by: clement valentine ]
 
H Sivad
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by clement valentine:
Hi guys,
It worked when I set "transacted" to false.

Old ---> QueueSession qsession = qconnect.createQueueSession(true,0);
New ---> QueueSession qsession = qconnect.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);

Also I realised that Session.AUTO_ACKNOWLEDGE is 1 and not 0! For that matter I can't find out what the static value '0' is in the javax.jms.Session API. Does '0' mean NO_ACKNOWLEDGEMENT?

According to the WLS doc. when "transacted" the ackowledge value is ignored. But somehow this didn't seem to work. Can anyone explain that for me please?

Whats the effect of setting the "transacted" to false? Does it mean that a rollback is not possible if anything down the line fails?

Thanks guys,
Clement

[ January 19, 2005: Message edited by: clement valentine ]


You should use "Session.AUTO_ACKNOWLEDGE" or "Session.CLIENT_ACKNOWLEDGE" or "Session.DUPS_OK_ACKNOWLEDGE" or "Session.SESSION_TRANSACTED" -- DON'T use the literal int value. If the implementation of these values changes, (in other words, they change the int values these symbolically represent) your application will be broken. Also, someone else can look at you code and see that you want the session transacted, whereas "3" would hold no clue to your intent.

That bit of coding style aside, message beans acknowledgement is automatically handled by the container. If you use bean managed transaction then the receipt is acknowledged by the container. Either way you specify the type of acknowledgement in the deployment descriptoras either AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE. So, the way the transaction is handled depends on Weblogic's implementation and the way you write and deploy your beans.

See This ServerSide article for more details about MDBs.

H.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic