[jboss-jira] [JBoss JIRA] (WFLY-3471) Scope of JMSContextProducer should be either @Request or @Tx not default
Elias Ross (JIRA)
issues at jboss.org
Mon Jun 9 15:03:15 EDT 2014
Elias Ross created WFLY-3471:
--------------------------------
Summary: 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
Affects Versions: 8.1.0.Final
Reporter: Elias Ross
Assignee: Stuart Douglas
>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.3#6260)
More information about the jboss-jira
mailing list