Class MessageFilter

java.lang.Object
com.totvs.tjf.messaging.MessageFilter

@Component("MessageFilter") public class MessageFilter extends Object
Message filter used in listeners.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MessageFilter(com.fasterxml.jackson.databind.ObjectMapper mapper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    contains(byte[] payload, String value)
    Check if it contains the value informed in the message.
    contains(com.totvs.tjf.messaging.context.TOTVSMessage<?> message, String value)
    Check if it contains the value informed in the message.
    get(byte[] payload, String path)
    Filters so that only specific messages fall into the listener.
    get(com.totvs.tjf.messaging.context.TOTVSMessage<?> message, String path)
    Filters so that only specific messages fall into the listener.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MessageFilter

      public MessageFilter(com.fasterxml.jackson.databind.ObjectMapper mapper)
  • Method Details

    • get

      public String get(byte[] payload, String path)
      Filters so that only specific messages fall into the listener. e.g. @StreamListener(target = TestExchange.INPUT, condition = "headers['type']=='CustomerWithFilter', @MessageFilter.get(payload,'content/name')=='Luke'")

      In this example, we are filtering so that, only when the content of the name field is Luke, the message is received by the listener. It receives as a parameter the payload and the path of what should be filtered.

      Parameters:
      payload - payload
      path - path
      Returns:
      the content if it has, or null.
    • get

      public String get(com.totvs.tjf.messaging.context.TOTVSMessage<?> message, String path)
      Filters so that only specific messages fall into the listener. It receives as a parameter the TOTVSMessage and the path of what should be filtered.
      Parameters:
      message - a TOTVSMessage
      path - path
      Returns:
      get(byte[], String).
    • contains

      public Boolean contains(byte[] payload, String value)
      Check if it contains the value informed in the message.
      Parameters:
      payload - payload
      value - value that is going to be checked in the payload
      Returns:
      true if it contains, otherwise false.
    • contains

      public Boolean contains(com.totvs.tjf.messaging.context.TOTVSMessage<?> message, String value)
      Check if it contains the value informed in the message.
      Parameters:
      message - a TOTVSMessage
      value - value that is going to be checked in the message
      Returns:
      contains(byte[], String).