Nine thousand events an hour, two kinds that matter
An airline's operations feed carries everything that happens to its flights: departures and arrivals, gate changes, new estimated times, crew swaps, fuel uploads, delay codes. On an ordinary day it publishes about 9,000 events an hour. The crew-alerts app texts cabin crew when their flight changes gate or time, and of those 9,000 events it needs around 600.
Its first version subscribed to the whole feed and sorted things out in its handler: parse the event, check the type, return early unless it was a gate or time change. That worked. It also meant the app received and parsed more than nine events in ten only to throw them away, and the rule deciding which events were its own sat in the middle of the texting code, where nobody changing a message template thought to look.
A step whose only job is to say no
A Message Filter takes that rule out and makes it a step of its own in the flow. It has one input and one output. Each message that arrives is tested against a condition, the predicate. A message that matches leaves on the output exactly as it arrived; a message that does not is dropped. A filter is a router with a single output: where a router chooses among several destinations, a filter chooses between one destination and none.
The filter sits in front of the crew app's copy of the feed. The dispatch screen subscribes to the same feed and still receives every event.
The crew-alerts handler can now assume that every message it receives is one to act on, and the filter can be tested by itself against a recorded hour of the feed.
What the predicate reads
The crew app's predicate is: the event type is GateChanged or TimeChanged, and the operating carrier is the airline itself rather than a codeshare partner whose crews it does not employ. Both parts are read from the message alone. That keeps the filter simple to reason about: a given message gets the same answer from every copy of the filter that runs the same rule, so several copies can run side by side.
A predicate that has to remember earlier messages, for instance to drop a repeat of one already seen, is no longer a plain filter. Its answer depends on what one copy has seen, so copies side by side disagree unless they share that state or split the keys between them; dropping repeats is Message Deduplication.
At the broker, or in front of the consumer
The rule does not have to live in the flow at all. When the broker supports subscription filters and most traffic is irrelevant to a consumer, filtering at the broker, with topic or subscription rules, beats filtering in the consumer: a message that fails the rule is never delivered, where a filter inside the consumer spends bandwidth and processing on 8,400 events an hour only to throw them away. Otherwise, use a Message Filter, or a separate topic, in front of the consumer. A separate topic builds one consumer's interest into the channels the producer publishes to, so it suits a split several consumers share. A Message Filter can run as the first step inside the consumer, keeping the rule apart from the handler while every message is still delivered. How a consumer hands its rule to the broker, and which parts of a message the broker can read, is the subject of Selective Consumer.
Check whose copy a filter drops. On a publish-subscribe channel each subscriber gets its own copy, so the crew filter in the diagram removes the crew app's copy and nothing else; the dispatch screen still sees every event. On a point-to-point channel there is only one copy, and a filter placed there removes the message for every receiver of that channel. Which kind you are on is the first thing Message Channel settles.
Count what you throw away
A few months in, the operations team moves its event names to a new convention and GateChanged becomes flight.gate.changed, TimeChanged becomes flight.time.changed. The feed keeps flowing. The filter receives every event as before, the predicate is false for all of them, and the crew app sends no texts. No log shows an error, because dropping a message that does not match is the filter doing its job. On the dashboards the morning looks quiet, until a crew member walks to a gate that changed an hour earlier.
Dropping is the filter's normal output, so measure it like output. Count the messages it passes and the ones it drops, broken down by event type, and alert when the pass count falls well below its usual level for that time of day. The crew filter normally passes around 600 an hour, and an hour with none is not a quiet hour. Drop counts by type show which new type the predicate is ignoring.
Do not send the dropped messages to a Dead Letter Channel. An event the crew app does not want has not failed, and 8,400 of them an hour would bury the few real failures that channel exists to show.
Messages, not fields, and one way out
Two neighbours are easy to mistake for this pattern. A Content Filter lets every message through and removes fields from it, such as passenger names on the way to an outside vendor; a Message Filter never changes a message, it decides whether the whole message goes on. A Content-Based Router sends each message to one of several outputs according to its content; a Message Filter has one output, and the alternative is nowhere. If the events the crew app rejects ought to go somewhere else, to a dispatch queue for instance, the step you want is a router.
The last requirement of the Message Transformation challenge is that distinction in one line: make clear that a Content Filter trims fields while a Message Filter would drop whole messages. Put both on the path as separate nodes, with their edges saying what each lets through, and then test the design against the airline's rename. If GateChanged changed its name tomorrow, which of your two nodes would go silent, and which would keep passing every message with fewer fields?