Class DefaultHeaderFilterStrategy
The general-purpose , Apache Camel's DefaultHeaderFilterStrategy: for
each direction a list of names, a regular expression and name prefixes; a header that matches any of them is
dropped — or, with set to false, only a header that matches is kept.
Send only Correlation-ID (a whitelist on the outgoing side):
context.AddToRegistry("correlationOnly", new DefaultHeaderFilterStrategy
{
OutFilter = ["Correlation-ID"],
FilterOnMatch = false,
});
From("direct://order").To("http://sap/orders?headerFilterStrategy=#correlationOnly");
In markup the same object is a <bean> with the properties of this class.
With false a direction with nothing configured drops every header: a whitelist
with no names lets nothing through. A header with a null value is dropped unless
is set. Names in the lists are compared without regard to case unless
is turned off.
public class DefaultHeaderFilterStrategy : IHeaderFilterStrategy
Inheritance
Implements
Properties
AllowNullValues
Let a header with a null value through; by default it is dropped.
public bool AllowNullValues { get; set; }
CaseInsensitive
Compare names in the lists without regard to case; true by default, as in Camel (header names of most
public bool CaseInsensitive { get; set; }
FilterOnMatch
What a match means. true (the default): a matching header is dropped — a blacklist. false: only
public bool FilterOnMatch { get; set; }
InFilter
Names matched in the incoming direction (message → exchange).
public IList<string> InFilter { get; set; }
InFilterPattern
A regular expression matched against the whole name in the incoming direction.
public string? InFilterPattern { get; set; }
InFilterStartsWith
Name prefixes matched in the incoming direction.
public IList<string> InFilterStartsWith { get; set; }
LowerCase
Also match the lower-cased name against the prefixes and, when is off, the lists.
public bool LowerCase { get; set; }
OutFilter
Names matched in the outgoing direction (exchange → message).
public IList<string> OutFilter { get; set; }
OutFilterPattern
A regular expression matched against the whole name in the outgoing direction.
public string? OutFilterPattern { get; set; }
OutFilterStartsWith
Name prefixes matched in the outgoing direction.
public IList<string> OutFilterStartsWith { get; set; }
Methods
FilterIncoming(string, object?, IExchange)
Whether the header name of an incoming message (a consumed message, a producer's reply) is
public virtual bool FilterIncoming(string name, object? value, IExchange exchange)
FilterOutgoing(string, object?, IExchange)
Whether the exchange header name is dropped instead of going into an outgoing message
public virtual bool FilterOutgoing(string name, object? value, IExchange exchange)