java.lang.Object
dk.cloudcreate.essentials.components.foundation.messaging.queue.PatternMatchingQueuedMessageHandler
All Implemented Interfaces:
QueuedMessageHandler

public class PatternMatchingQueuedMessageHandler extends Object implements QueuedMessageHandler
Pattern matching QueuedMessageHandler for use with DurableQueues's
The PatternMatchingQueuedMessageHandler will automatically call methods annotated with the @MessageHandler annotation and where the 1st argument matches the actual Message payload type (contained in the Message.getPayload() provided to the QueuedMessageHandler.handle(QueuedMessage) method)

Each method may also include a 2nd argument that of type QueuedMessage in which case the event that's being matched is included as the 2nd argument in the call to the method.
The methods can have any accessibility (private, public, etc.), they just have to be instance methods.

Example:


 public class MyMessageHandler extends PatternMatchingQueuedMessageHandler {

         @MessageHandler
         public void handle(OrderEvent.OrderAdded orderAdded) {
             ...
         }

         @MessageHandler
         private void handle(OrderEvent.ProductRemovedFromOrder productRemovedFromOrder, QueuedMessage queuedMessage) {
           ...
         }
 }