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.
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:
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.
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.
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.