geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <>
Subject Re: Sharing resources in an MDB
Date Fri, 16 Mar 2007 13:08:59 GMT

On Mar 15, 2007, at 9:02 PM, Glenn Owen wrote:

> I'm sure I should have learned this in MDB 101, but I'll ask here
> anyway.
> I have an MDB that reads incoming messages, does a bunch of work, and
> then writes data to another outgoing JMS Queue.
> As the load increases, Geronimo will create multiple instances of the
> MDB and I was getting exceptions after about the 10th instance,  
> because
> I could not get enough outgoing Queue connections.
> Originally each MDB was looking up the outgoing connection factory and
> queue and creating a connection,session,producer in onMessage().
> But since I was getting the above error, I modified it to get the
> outgoing  connection factory,queue and connection in ejbCreate() and
> holding onto those is *static* variables, so all instances of the MDB
> shared the same connection.
> The onMessage() still gets it's own session and producer.
> That solved my problem, but I'm not sure it is "right".
> It is OK to share the factory/queue/connection across multiple  
> instances
> of an MDB?

It might possibly work for activemq if you don't use any  
transactions, but if you use transactions I would expect it to  
completely break and give pretty random behavior.  I don't think  
there's any reason to expect it to work even without transactions.

I have trouble keeping all the places you can configure sizes  
straight, but one way to limit the number of active mdbs is to give  
the inbound resource adapter its own thread pool and limit that  
size.  I think there's a more direct way but don't recall what it is.

If the number of outbound connections is at least the number of mdbs  
I would expect you wouldn't run into problems.

Maybe someone with more actual experience can give some more informed  

david jencks


View raw message