messaging icon indicating copy to clipboard operation
messaging copied to clipboard

MessageListeners should be as simple as lambda expressions

Open glassfishrobot opened this issue 11 years ago • 5 comments

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.

glassfishrobot avatar Mar 21 '13 17:03 glassfishrobot

  • Issue Imported From: https://github.com/javaee/jms-spec/issues/118
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: Unassigned

glassfishrobot avatar Feb 12 '18 18:02 glassfishrobot

@glassfishrobot Commented Reported by genomeprjct

glassfishrobot avatar Mar 21 '13 17:03 glassfishrobot

@glassfishrobot Commented @nigeldeakin said: 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);}
);

glassfishrobot avatar Mar 21 '13 20:03 glassfishrobot

@glassfishrobot Commented This issue was imported from java.net JIRA JMS_SPEC-118

glassfishrobot avatar May 02 '17 10:05 glassfishrobot

I don't think this has sufficient detail. I would just close it to reduce clutter.

Reza Rahman Jakarta EE Ambassador, Author, Blogger, Speaker

Please note views expressed here are my own as an individual community member and do not reflect the views of my employer.

m-reza-rahman avatar May 29 '21 21:05 m-reza-rahman