Tags: zarusz/SlimMessageBus
Tags
Adds message header filtering for consumers Enables advanced routing and dispatching of messages to specific consumers or invokers based on message headers. This allows multiple logical consumers to share the same transport path (topic/queue). - Introduces new `.Filter()` methods on the consumer builder for configuration. - Implements runtime evaluation of filter predicates during invoker selection, supporting both consumer-level and per-invoker filters with clear precedence. - Adds robust error handling for filter predicates, treating exceptions as non-matches and logging warnings. - Updates documentation with a dedicated section, API details, examples, and troubleshooting. - Includes a unit test to verify correct message dispatching with header-based filters. Adds consumer message filtering by headers Introduces the ability to filter incoming messages for specific consumers or invokers based on message headers. This enables advanced routing scenarios where multiple logical consumers share the same transport topic or queue. * Allows configuring filter predicates via the `.Filter()` method on the consumer builder. * Filters are evaluated at runtime during invoker selection, supporting both consumer-level and per-invoker predicates with clear precedence. * Includes robust error handling for filter predicates, treating exceptions as non-matches and logging warnings. * Updates the documentation with a dedicated section, API details, examples, and troubleshooting. * Adds a unit test to ensure correct message dispatching with header-based filters. Signed-off-by: Thomas Anderson <[email protected]> Enhances consumer matching with message context The `TryMatchConsumerInvoker` method now includes `messageHeaders` and the raw `transportMessage` as parameters. This allows for more dynamic and context-aware selection of message consumers, enabling routing decisions based on runtime header information or transport-specific details, rather than solely on message type. Signed-off-by: Thomas Anderson <[email protected]> Adjusts test filter signature Aligns the message consumer filter delegate in tests with the updated API that now provides access to the message object alongside headers. Ensures compatibility with the new filter signature. Signed-off-by: Thomas Anderson <[email protected]> Refactors consumer filter delegate type Introduces a new generic `ConsumerFilter` delegate to provide a more explicit and type-safe contract for filtering messages based on headers and the transport message. Updates `ConsumerSettings` and related interfaces to use this new delegate type for the `Filter` property, improving consistency and clarity across the configuration. Removes a less specific `Filter` builder overload from `AbstractConsumerBuilder` to streamline the API towards the more comprehensive `(headers, message)` filter signature, which now leverages the new delegate. Adjusts filter selection logic in `MessageProcessor`. If a specific invoker has a filter configured, that filter is now bypassed, and no fallback to a parent consumer filter occurs. If the invoker has no specific filter, it defaults to the parent consumer's filter. Signed-off-by: Thomas Andoerson <[email protected]> Fixed test refactored message processor as per PR comments to reduce the memory allocation on the single invoker scenario Signed-off-by: Thomas Andoerson <[email protected]>
PreviousNext