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

Antonio Goncalves antonio.goncalves at gmail.com
Mon Aug 24 13:42:41 EDT 2015


Nigel, what do you mean by :

"The application must obtain an instance of the JMS listener bean using
dependency injection"

In your examples, it looks like a CDI bean cannot start listening if not
injected :

@WebServlet("/myjmsservlet1")
 public class MyJMSServlet1 extends HttpServlet {

   *@Inject MyDepScopeListenerBean* myDepScopeListenerBean;

   public void service(ServletRequest req, ServletResponse res) throws
IOException, ServletException {
      ...
   }
 }


Did I understand well ? Is this the case ? Just like a MDB, I would like a
CDI bean to start listening to a message without being injected, as soon as
the application starts. Something like :

*@ApplicationScoped*
public class MyListenerBean{


 @JMSListener(lookup="java:global/java:global/Trades",type=JMSListener.Type.TOPIC
)
   public void deliver(Message message) {
     ...
   }
}

Or if we manage to get the @Startup annotation to Commons Annotation :

*@Startup*
public class MyListenerBean{


 @JMSListener(lookup="java:global/java:global/Trades",type=JMSListener.Type.TOPIC
)
   public void deliver(Message message) {
     ...
   }
}


Just thinking here

Antonio

On Mon, Aug 24, 2015 at 6:30 PM, Nigel Deakin <nigel.deakin at oracle.com>
wrote:

> Over in the JMS 2.1 expert group I've just published some proposals to
> allow any CDI managed bean in a Java EE
> application to listen for JMS messages. This would be implemented as a
> standard CDI portable extension and would become
> a mandatory part of a full Java EE 8 application server.
>
> I would welcome any comments from the CDI spec experts here. If you're
> interested in helping, please take a look at
> https://java.net/projects/jms-spec/pages/CDIBeansAsJMSListeners
> and send comments or questions to me or to the public
> users at jms-spec.java.net alias.
>
> Thanks,
>
> Nigel
> JMS 2.1 specification lead
> _______________________________________________
> 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.
>



-- 
Antonio Goncalves
Software architect, Java Champion and Pluralsight author

Web site <http://www.antoniogoncalves.org> | Twitter
<http://twitter.com/agoncal> | LinkedIn <http://www.linkedin.com/in/agoncal> |
Pluralsight
<http://pluralsight.com/training/Authors/Details/antonio-goncalves> | Paris
JUG <http://www.parisjug.org> | Devoxx France <http://www.devoxx.fr>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20150824/55f410a4/attachment.html 


More information about the cdi-dev mailing list