[JMS_SPEC-118] MessageListeners should be as simple as lambda expressions Created: 21/Mar/13  Updated: 10/May/13

Status: Open
Project: jms-spec
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: John D. Ament Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: jms21-forreview-minor

 Description   

It should be possible to define a lambda expression as a message listener, to avoid needing to implement the interface.

This of course would require using Java SE 8 in the runtime of a JMS provider.



 Comments   
Comment by Nigel Deakin [ 21/Mar/13 ]

Can you please say a bit more about what you have in mind?

javax.jms.MessageListener is a "functional interface" (with only one abstract method) so (if you're using Java SE 8) so even using the existing API you could specify a lambda expression instead of supplying a MessageListener implementation:

consumer.setMessageListener(
   m -> {String payload=m.getBody(string.class);
         System.out.println("Received message:"+payload);}
);
Generated at Mon Apr 27 05:17:16 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.