-
1. Clustered Message Driven Beans
rohantalip Jun 15, 2005 7:01 AM (in response to rohantalip)Hi,
I managed to get a HASingleton (i.e. cluster-wide singleton) QueueReceiver to work (instead of an cluster-wide singleton MDB, which did not appear possible).
I have another problem now:
When the HASingleton JMS server fails over to another JBoss instance, is it possible to configure Message Driven Beans on multiple JBoss servers in the cluster to automatically reconnect their (Queue)Connection to the new JBoss instance?
Right now I'm getting the infamous "ping timeout" exception every minute or so:java.io.IOException: ping timeout. at org.jboss.mq.Connection$PingTask.run(Connection.java:1377) at EDU.oswego.cs.dl.util.concurrent.ClockDaemon$RunLoop.run(ClockDaemon.java:364) at java.lang.Thread.run(Thread.java:595)
This is even with specifying the HA-JNDI port of 1100. Actually this is the default in jboss-4.0.1sp1/server/all/deploy/jms/hajndi-jms-ds.xml
If I had a handle to the Connection used by the Message Driven Bean I could call setExceptionListener() to reconnect when the HASingleton JMS server moves but because the connection is not exposed by the container (or probably more accurately by the EJB 2.0 specification) I don't think this is possible to do in the MDB code.
I have looked at some of the JBoss 4.0.1sp1 code relating to JMS and Connections etc, but I can't see anything that indicates that a ping timeout exception will be caught and the Connection recreated.
Am I missing something?
Is it at all possible to configure this via MDB deployment descriptors or in the standardjboss.xml or deploy/jms/hajndi-jms-ds.xml files?
Any help appreciated.
Thanks,
Rohan -
2. Catching onException() for MDBs
rohantalip Jun 29, 2005 7:56 AM (in response to rohantalip)Hi,
This is just a follow up message. Since I received an email asking what I did about this, I thought it would be better to share it on the forum.If I had a handle to the Connection used by the Message Driven Bean I could call setExceptionListener() to reconnect when the HASingleton JMS server moves but because the connection is not exposed by the container (or probably more accurately by the EJB 2.0 specification) I don't think this is possible to do in the MDB code.
I have looked at some of the JBoss 4.0.1sp1 code relating to JMS and Connections etc, but I can't see anything that indicates that a ping timeout exception will be caught and the Connection recreated.
...
Is it at all possible to configure this via MDB deployment descriptors or in the standardjboss.xml or deploy/jms/hajndi-jms-ds.xml files?
I was not able to work out how to do this for Message Driven Beans. I did look very briefly at ActiveMQ and was told on the ActiveMQ mailing list that ActiveMQ driven MDBs reconnect to the server after a JMS broker restart.
However after discussions with our technical architect, we decided to keep it simple (for now) and stick with JBossMQ (rather than introducing yet another software package), although I changed the MDBs into slightly more complex JBoss services that had QueueReceivers that polled the JMS queues.
This meant that I had more control over the connection and could call setExceptionListener() and handle the exceptions whenever the JMS broker moved to another JBoss instance (and so reconnect appropriately).
One thing I found necessary to do before reconnecting, was to close() and stop() the old connection before getting a new connection, otherwise I continued to see 'ping timeout' being logged from the old connection.
This now works very well for us. It is a pity I couldn't get it to work with MDBs as they are simpler to deal with.
Again, if anyone knows how to do this with MDBs (and JBossMQ) with code and/or deployment descriptors, please let me know, although it is a little late as I have already changed my code as I mentioned above.
Regards,
Rohan -
3. Re: Catching onException() for MDBs
pjw Jul 13, 2005 5:20 AM (in response to rohantalip)Hello Rohan,
a follow-up to your follow-up..."Rohan Talip" wrote:
One thing I found necessary to do before reconnecting, was to close() and stop() the old connection before getting a new connection, otherwise I continued to see 'ping timeout' being logged from the old connection.
Assume you close() your connection and when trying to get a new connection, you are not able to do so, e.g. because of a permanent connection problem.
Will this result in a lost connection and a lost ExceptionHandler? Which again means you will not be able to receive any onException()-messages and then again not be able to handle this correctly and establish a new connection?
cheers,
pj -
4. Re: Clustered HASingleton MDB?
pjw Jul 14, 2005 3:32 AM (in response to rohantalip)hello,
to answer my own question: close() on the connection does disable the ExceptionListener. No more onException() will be received. This should not be a problem, however, as we now know the state of the connection and can e.g. spawn a Thread which can periodically try to establish a new connection.
cheers,
pj