I am trying to deploy a MDB application onto JBoss 5.1.0 instance. The MDB in discussion has a timer associated with it. I am seeing two issues that I am trying to get to the root of:
1. The messages that I am sending from a ServletContextListener implementation are not being received by the MDB. I do not see any exceptions in the server log file, but in looking at the admin console, I see that the message count on the queue is not going up either, making me think that either the counter on the console is buggy, or really my messages are not being delivered. What is annoying is that JBoss is silent about it, does not want to give any error!
2. The MDB has a timer associated with it. The way I have defined the timer is that it should fire the first time 5 minutes after the timer is setup, and then every 30 minutes. The purpose of sending the message from the ServletContextListener implementation above is to initialize/setup the timer. Unfortunately, although as i note above, the messages i am sending are not being processed, but, strangely enough, the method that is annotated as @Timeout does fire up immediately on deployment. Why is this happening.
For problem #1 above, I think it has something to do with the way I have set up my queue and how I am mapping the queue inside the ServletContextListener and the MDB setup itself. I have tried many combos, but all in vain.
For problem #2 above, i am really in the dark...do not know why it is displaying this behavior.
Enough said, some code now:
I define my destinations inside a *-destinations-service.xml file, which is pakaged inside the META-INF folder of the ejb-jar file. The definition looks like this:
My MDB looks like this:
My ServletContextListener Implementation looks like this:
Wrong value. By default when you don't specify the JNDI name for your queue in your queue config file (the *-service.xml), JBoss binds it to queue/[name-of-the-queue]. So in this example, it's going to be bound to queue/Deals (and the other one at queue/RssDeals).
So change the "destination" activation property value to:
To answer your question - Yes, I did, and it did not make a difference.
I did try something else though, and that worked. I basically built a standalone java client to send messages to the two queues, and that did activate the MDBs. So that makes me believe that the MDBs are set up properly, its is only the part where i am sending messages from inside my ServletContextListener that is not working for some reason. My Java client impl looks like this:
And my MDB looks like this:
Finally, my ServletContextListener impl looks like this:
And I do see some more strange behavior on the timer, but i will save that question for another thread.
Ok, so I had another breakthrough today. After carefully examining the difference between my standalone java client that was sending the messages to the servletcontextlistener impl that was not successful, I saw only one difference - the parameters that I was passing in the createSession() method of the Connection. In the client, it looks like this:
In the ServletContextListener impl, it looked like this:
So, while I was trying to get a non transacted session in the java client, I was trying to get a transacted session from inside the servletcontextlistener impl. I changed the boolean parameter to false, and sure enough, everything came together!
But surely this is not a good thing. My question is, how can I get a transacted session? I tried using the XAConnectionfactory instead of Connectionfactory to get the jmsConnection, but that did not help. Any ideas please?
In your servlet code, I don't see any transaction being started/commited before and after sending the messages. You might want to use the UserTransaction to begin/commit the transaction in the servlet code, if you want to use transacted queue session.
By the way, why do you want a transacted queue session? Do you want to send multiple messages from the same session as part of a transaction? i.e. msg1 and msg2 will be sent as a group when using the transacted queue session. Is this the behaviour you desire?