jms-spec
  1. jms-spec
  2. JMS_SPEC-118

MessageListeners should be as simple as lambda expressions

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      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.

        Activity

        Hide
        Nigel Deakin added a comment -

        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);}
        );
        
        Show
        Nigel Deakin added a comment - 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);} );

          People

          • Assignee:
            Unassigned
            Reporter:
            John D. Ament
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: