[cdi-dev] JMS 2.1: Proposal to allow any CDI managed bean in a Java EE application to listen for JMS messages

Werner Keil werner.keil at gmail.com
Wed Aug 26 08:26:16 EDT 2015


I can confirm, in my example for routing events, the BookingBean injected
into a BookingMDB and listening Observer class also had to
be @RequestScoped.

Werner

On Wed, Aug 26, 2015 at 2:03 PM, <cdi-dev-request at lists.jboss.org> wrote:

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


More information about the cdi-dev mailing list