jsr343-experts@jms-spec.java.net

[jsr343-experts] Re: JMS Support for DI

From: Nigel Deakin <nigel.deakin_at_oracle.com>
Date: Fri, 02 Sep 2011 18:42:59 +0100

Reza,

On 30/08/2011 21:58, Reza Rahman wrote:

> * The issue of correct scoping for the injected JMS objects is pretty critical to guaranteeing scalability across
> different container implementations/applications/environments. I do know that Seam JMS currently has these injected
> objects in the dependent scope, in part because there is not yet a standard @TransactionScoped for CDI as of yet. The
> problem is that having these objects in the dependent scope will eventually cause the connection pool to run out if the
> objects are injected into very long-lived objects such as Servlets, pooled stateless session beans, singletons and
> application scoped services. This is basically the opposite problem of the connection thrashing that happens with Spring
> JmsTemplate.

I agree that the built-in CDI scopes don't seem quite right for JMS objects. Your suggestion for a "transaction scope"
sounds right. Do you have a definition of what such a scope would mean? It leaves me wondering why it's not already
there as a built-in scope. Is this something we should take up with the CDI folks?

> JPA avoids this problem by making the persistence context transaction scoped by default and caching underlying
> logical sessions/connections per transaction (and limiting the extended persistence scope option to stateful session
> beans).

You mean we should follow the model of a container-managed entity manager?

> We can specify the same thing for injected JMS objects in addition to specifying inter-dependencies for
> intermediate JMS objects to maximize resource re-use.

> For reference, I outlined the solution that we had for Resin in my initial detailed proposal.

I'm not sure what particular proposal you're referring to. Can you point me to the appropriate email in the archive?
(You can link to archived posts such as this:
http://java.net/projects/jms-spec/lists/jsr343-experts/archive/2011-07/message/46

Thanks,

Nigel