ediverse Explore the platform

Spotlight PEPPOL BIS Billing 3.0 The EU e-invoicing mandate is here — France Sept 2026, Belgium Jan 2026, Germany 2025.

Selective Consumer

Filtering on the queue side rather than in the consumer code — to avoid pulling 1000 messages just to drop 999.

Problem

A shared queue carries messages destined to several consumers per a criterion (partner, type, environment). A naive consumer pulls everything and filters in code — wasted bandwidth and CPU.

Forces

  • A single queue is often imposed by a shared EDI broker; per-consumer queues are not always possible.
  • Pulling then dropping consumes the message lock, blocks other consumers, and inflates the commit log.
  • Queue-side filtering applies only to headers / properties, not to encrypted payload.
  • An ill-fitted selector can leave a message stuck if no consumer matches.

Solution

Configure the consumer with a broker-side selector. Under JMS, the selector is a SQL-like expression on headers (`AS2_PARTNER = 'WALMART' AND DOC_TYPE = 'ORDERS'`). Under Kafka, rely on key-based partitioning plus a Streams filter. Under RabbitMQ, use a binding key on a topic exchange. The result: each consumer receives only its messages, no pull-and-drop.

EDI implementation

In EDI, Selective Consumer is used to split processing per partner (one consumer per major retailer Walmart / Target / Amazon) without duplicating the queue. Headers are populated by the AS2 Gateway at ingestion: `AS2_FROM`, `AS2_TO`, `DOC_TYPE`. Camel consumers subscribe with `selector='DOC_TYPE = ORDERS'`. Beware of relying on headers not guaranteed (the partner may omit `AS2_FROM` in some signed-only flows).

Anti-patterns

  • Too-broad selector that matches everything — the pattern degenerates into disguised pull-and-drop.
  • Selector that depends on payload (impossible broker-side) — confused with an application Message Filter.
  • Overlapping selectors across consumers — same message pulled twice.
  • Non-exhaustive selectors (no consumer matches) — message stuck until TTL or DLQ.

Sources