Class AllowListMessageHeaderSelector

java.lang.Object
org.springframework.integration.selector.AllowListMessageHeaderSelector
All Implemented Interfaces:
GenericSelector<Message<?>>, MessageSelector

public class AllowListMessageHeaderSelector extends Object implements MessageSelector
The MessageSelector implementation to apply patterns on the value of the specified header in the message. If no header value, the message is accepted by default. Set setAcceptNulls(boolean) to false to reject messages with null header values. Otherwise, it is accepted only if the header value matches one of the patterns positively.

This selector can be used in any scenario where the message's metadata should be trusted before it is used in the downstream flow.

Since:
6.5.9
Author:
Artem Bilan
See Also:
  • Constructor Details

    • AllowListMessageHeaderSelector

      public AllowListMessageHeaderSelector(String header, String... patterns)
      Create an instance with the specified header and patterns.
      Parameters:
      header - the message header to validate.
      patterns - the simple patterns to match ignoring a case; also supports negated ('!') patterns. First match wins (positive or negative).
  • Method Details

    • setAcceptNulls

      public void setAcceptNulls(boolean acceptNulls)
      Whether null values from the header are considered as valid.
      Parameters:
      acceptNulls - false to not accept null values.
    • accept

      public boolean accept(Message<?> message)
      Specified by:
      accept in interface GenericSelector<Message<?>>
      Specified by:
      accept in interface MessageSelector