Re: Implementing pseudo-Message Driven Bean in WebSphere 4
Sunday, October 13, 2002 12:20 AM
The situation you describe will work perfectly with MDB..
But since you cannot use it (Why don't you upgrade to EA?):
I've used a session pool by myself.
I use it for any object wishing to send a message to a queue.
My module encapsulate all JMS code from any other object wishing to send a message.
In addition, you need to follow JMS restrictions - Use a session per thread model.
So, In order to do this, you can design an Hashtable:
The key could be the thread Name and the value is an object holding queue senders for this thread.
This is one way to reuse the session and senders created from it for the specific thread.
Each thread wishing to send a message will first check the table, if it finds a session, then it can use it for sending, otherwise, a new object is created for the thread and so on...
Now for receiving:
When you use a simple queue listener - let's say it is blocked till a message arrives, it will handle the messages one by one and the queue might get filled.
I don't know what is happening when creating many listeners on the same queue because in MDB, the load balancing is done by the App. Server and you need to create one for your listeners.
Try to send many messages and create 2 or more listeners - if you use threads, then each thread should use a session and create a queue listener.
The QueueConnection and QueueConnectionFactory can be used by all sessions.
Hope it helps!