messaging
messaging copied to clipboard
MessageListeners should be as simple as lambda expressions
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.
- Issue Imported From: https://github.com/javaee/jms-spec/issues/118
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: Unassigned
@glassfishrobot Commented Reported by genomeprjct
@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 Commented This issue was imported from java.net JIRA JMS_SPEC-118
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.