[jboss-jira] [JBoss JIRA] (WFLY-3471) Scope of JMSContextProducer should be either @Request or @Tx not default

Stuart Douglas (JIRA) issues at jboss.org
Thu Jun 12 17:53:38 EDT 2014


     [ https://issues.jboss.org/browse/WFLY-3471?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stuart Douglas updated WFLY-3471:
---------------------------------

       Assignee: Jeff Mesnil  (was: Stuart Douglas)
    Component/s: JMS


> Scope of JMSContextProducer should be either @Request or @Tx not default
> ------------------------------------------------------------------------
>
>                 Key: WFLY-3471
>                 URL: https://issues.jboss.org/browse/WFLY-3471
>             Project: WildFly
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: CDI / Weld, JMS
>    Affects Versions: 8.1.0.Final
>            Reporter: Elias Ross
>            Assignee: Jeff Mesnil
>
> From this email thread.
> Note that if you @Inject JMSProducer into a @ApplicationScoped bean then that's the scoping used, although it's not correct as the scope should be either @Request or @TransactionScoped
> To: users at jms-spec.java.net
> Subject: [jms-spec users] Re: Confusion about JMSProducer methods and CDI
> On 05/06/2014 19:29, Elias Ross wrote:
> >
> > The other question I had was the scoping for CDI. For example:
> >
> > @ApplicationScoped
> > public class MyClient {
> >     @Inject JMSContext context;
> > }
> >
> > public class MyServlet extends HttpServlet {
> >     @Inject MyClient client;
> > }
> >
> > Then JMSContext ends up being potentially shared between multiple
> > threads. I would expect the scoping of JMSContext to be request, not
> > @Dependent here.
> >
> Why do you say that the "JMSContext ends up being potentially shared between multiple threads"?
> The scope of the injected JMSContext is defined in the JMS 2.0 spec, section 12.4.4. "Scope of injected JMSContext 
> objects". Essentially, if there's a transaction in progress then the injected JMSContext will have transaction scope, 
> otherwise it will have request scope.
> It looks like you're in a servlet here, and you haven't started a transaction, so the injected JMSContext must have 
> request scope.
> The scope of the injected JMSContext is defined in the JMS 2.0 spec, section 12.4.4. "Scope of injected JMSContext objects". Essentially, if there's a transaction in progress then the injected JMSContext will have transaction scope, otherwise it will have request scope.
> It looks like you're in a servlet here, and you haven't started a transaction, so the injected JMSContext must have request scope.



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)


More information about the jboss-jira mailing list