dcsimg
Implementing pseudo-Message Driven Bean in WebSphere 4
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Robert_Pappas
Posted On:   Saturday, October 12, 2002 11:23 PM

Greetings! I have a question thats a little similar to a few that have been posted here....and yet different. I have WebSphere Advanced Server 4.0.4. It does not implement Message Driven Beans. So, I'm trying to code a similar mechanism by myself by writing a Servlet (or some kind of class) that will listen for incoming messages over JMS (we use MQ Series), and then will send a reply message to the "Reply-To" queue specified in the incomming message. (So I don't have any advance knowledge of where I'm replying to until I read the message.) I've worked through all the Willy Farrell tutorials, and read all the information I can find on the IBM site, but I still don't see THIS very speci   More>>

Greetings!



I have a question thats a little similar to a few that have been posted here....and yet different.



I have WebSphere Advanced Server 4.0.4. It does not implement Message Driven Beans. So, I'm trying to code a similar mechanism by myself by writing a Servlet (or some kind of class) that will listen for incoming messages over JMS (we use MQ Series), and then will send a reply message to the "Reply-To" queue specified in the incomming message. (So I don't have any advance knowledge of where I'm replying to until I read the message.)



I've worked through all the Willy Farrell tutorials, and read all the information I can find on the IBM site, but I still don't see THIS very specific problem addressed in any detail.



Obviously the sample QReceiver program works well until it gets requests faster than it can process. So I want to create a pool of "something" somehow. I'm a good Java Thread programmer, but I need to know where I should be threading and re-using which objects in this case. (Given that my case is a bit different that others posted here.)



What's all this I hear about "Pools of Sessions" and "Pools of Worker Threads". What are you guys doing exactly? I even saw someone post something about a hashtable of threads. What on earth is that doing? :)



Any help, articles, sample code etc. would GREATLY be appreciated! :)



Thanks!



Robert Pappas

rpappas@sound.net

   <<Less

Re: Implementing pseudo-Message Driven Bean in WebSphere 4

Posted By:   Boaz_Inbal  
Posted On:   Sunday, October 13, 2002 12:20 AM

Hi Robert!


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!
Boaz
About | Sitemap | Contact