<div dir="ltr">I can confirm, in my example for routing events, the BookingBean injected into a BookingMDB and listening Observer class also had to be @RequestScoped.<br><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><p style="margin:0px;font-size:13px;border-collapse:collapse"><span lang="EN-US" style="font-family:Calibri">Werner </span></p></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Aug 26, 2015 at 2:03 PM,  <span dir="ltr">&lt;<a href="mailto:cdi-dev-request@lists.jboss.org" target="_blank">cdi-dev-request@lists.jboss.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Send cdi-dev mailing list submissions to<br>
        <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:cdi-dev-request@lists.jboss.org">cdi-dev-request@lists.jboss.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:cdi-dev-owner@lists.jboss.org">cdi-dev-owner@lists.jboss.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of cdi-dev digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. Re: JMS 2.1: Proposal to allow any CDI managed bean in a Java<br>
      EE application to listen for JMS messages (Nigel Deakin)<br>
   2. Re: JMS 2.1: Proposal to allow any CDI managed bean in a Java<br>
      EE application to listen for JMS messages (John D. Ament)<br>
<br>
----------------------------------------------------------------------<br>
<br>Message: 2<br>
Date: Wed, 26 Aug 2015 11:10:11 +0000<br>
From: &quot;John D. Ament&quot; &lt;<a href="mailto:john.d.ament@gmail.com">john.d.ament@gmail.com</a>&gt;<br>
Subject: Re: [cdi-dev] JMS 2.1: Proposal to allow any CDI managed bean<br>
        in a Java EE application to listen for JMS messages<br>
To: Nigel Deakin &lt;<a href="mailto:nigel.deakin@oracle.com">nigel.deakin@oracle.com</a>&gt;,     arjan tijms<br>
        &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt;,        Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>&gt;<br>
Cc: cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
Message-ID:<br>
        &lt;CAOqetn8LhNvq+4ELzuq-MLA3=6eVP3-k_AMQ8502=<a href="mailto:ag4jy4ZCg@mail.gmail.com">ag4jy4ZCg@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
On Wed, Aug 26, 2015 at 6:53 AM Nigel Deakin &lt;<a href="mailto:nigel.deakin@oracle.com">nigel.deakin@oracle.com</a>&gt;<br>
wrote:<br>
<br>
&gt; On 26/08/2015 10:51, arjan tijms wrote:<br>
&gt; &gt; On Wed, Aug 26, 2015 at 11:09 AM, Romain Manni-Bucau<br>
&gt; &gt; &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>&gt; wrote:<br>
&gt; &gt;&gt; Agree for provided scope but JMS + short time scopes will not match<br>
&gt; well in<br>
&gt; &gt;&gt; practise so i would worry more about not &quot;default&quot; scopes which can miss<br>
&gt; &gt;&gt; these events.<br>
&gt; &gt;<br>
&gt; &gt; Short lived scopes like @RequestScoped may not be the best match indeed.<br>
&gt; &gt;<br>
&gt; &gt; Additionally, @RequestScoped is kinda assumed to be an &quot;@ThreadScoped&quot;<br>
&gt; &gt; thing, e.g. there&#39;s the expectation that only the current thread will<br>
&gt; &gt; access it. If the JMS provider will asynchronously call a method on<br>
&gt; &gt; the bean instance from another thread, then this breaks this<br>
&gt; &gt; assumption.<br>
&gt;<br>
&gt; That&#39;s an interesting point. Is there anything in the CDI spec which would<br>
&gt; forbid the use of a @RequestScoped JMS<br>
&gt; listener bean from another thread?<br>
&gt;<br>
<br>
The CDI spec still mandates that a request scope is started for delivery to<br>
MDBs.  See <a href="http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#request_context" rel="noreferrer" target="_blank">http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#request_context</a><br>
<br>
The JMS provider would be responsible for retrieving a contextual reference<br>
to the bean and then invoking the method.  The container should still be<br>
responsible for starting the request context (If I read this correctly).<br>
<br>
Likewise, we could say that a @TransactionScoped bean also applies here,<br>
since a JTA transaction should have been started by the RA.<br>
<br>
<br>
&gt;<br>
&gt; Perhaps all that is needed is to make it clear to users that this is what<br>
&gt; would happen. The same issue would arise if<br>
&gt; the user injected a dependent-scoped JMS listener bean into a<br>
&gt; @RequestScoped bean.<br>
&gt;<br>
&gt; It&#39;s worth considering threading more generally. Although the JMS provider<br>
&gt; (resource adapter, actually) can make sure<br>
&gt; that the callback method won&#39;t be called from multiple JMS provider<br>
&gt; threads at the same time, it can&#39;t guarantee that an<br>
&gt; application thread won&#39;t be calling a business method on the bean at the<br>
&gt; same time. (Would it want to?)<br>
&gt;<br>
&gt; Nigel<br>
&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;<br>
&gt; Note that for all code provided on this list, the provider licenses the<br>
&gt; code under the Apache License, Version 2 (<br>
&gt; <a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas<br>
&gt; provided on this list, the provider waives all patent and other<br>
&gt; intellectual property rights inherent in such information.<br>
&gt;<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.jboss.org/pipermail/cdi-dev/attachments/20150826/bb408008/attachment-0001.html" rel="noreferrer" target="_blank">http://lists.jboss.org/pipermail/cdi-dev/attachments/20150826/bb408008/attachment-0001.html</a><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>).  For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br>
<br>
End of cdi-dev Digest, Vol 57, Issue 24<br>
***************************************<br>
</blockquote></div><br></div></div>