--- url: "http://www.enterpriseintegrationpatterns.com/MessageSelector.html" titulek: "Selective Consumer - Enterprise Integration Patterns" h1: "" popis: "How can a message consumer select which messages it wishes to receive?" jazyk: "en" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-15 15:34:42" znaku: 6768 slov: 664 kodovani: "utf-8" sha256: "200eeab56af2adb679a5a81c4edc0e97a1e0a1f24a65902cc2a8d6f2c90d17d1" --- | | Selective Consumer[Messaging Patterns](index.html) » [Messaging Endpoints](MessagingEndpointsIntro.html) | [Contents](toc.html)[⇐ Prev](MessageDispatcher.html)[Next ⇒](DurableSubscription.html) | | --- | --- | --- | An application is using [*Messaging*](Messaging.html). It consumes [*Message*](Message.html)s from a [*Message Channel*](MessageChannel.html), but it does not necessarily want to consume all of the messages on that channel, just some of them. How can a message consumer select which messages it wishes to receive? Make the consumer a *Selective Consumer*, one that filteres the messages delivered by its channel so that it only receives the ones that match its criteria. There are three parts to this filtering process: 1. **Specifying Producer** — Specifies the message’s selection value before sending it. 2. **Selection Value** — One or more values specified in the message that allow a consumer to decide whether to select the message. 3. **Selective Consumer** — Only receives messages that meet its selection criteria. When multiple *Selective Consumer*s are used with a [*Point-to-Point Channel*](PointToPointChannel.html), they effectively become [*Competing Consumers*](CompetingConsumers.html) that are also selective. If two consumer’s criteria overlap, and a message’s selection value meets both of their criteria, either consumer can consume the message. Consumers should be designed to ensure that at least one of them is eligable to consume every valid selection value. Otherwise, a message with an unmatched selection value will never be consumed and will clutter the channel forever (or at least until [*Message Expiration*](MessageExpiration.html) occurrs). When multiple *Selective Consumer*s are used with a [*Publish-Subscribe Channel*](PublishSubscribeChannel.html), each message will be delivered to each subscriber, but a subscriber will simply ignore its copy of a message that does not fit its criteria. Once a consumer decides to ignore a message, the messaging system can discard the message since it has been successfully delivered and will never be consumed. A messaging system can optimize this process by not even delivering a message it knows the consumer will ignore, thereby decreasing the number of copies of a message that must be produced and transmitted. This behavior of discarding ignored messages is independent of whatever [*Guaranteed Delivery*](GuaranteedMessaging.html), [*Durable Subscriber*](DurableSubscription.html), and/or [*Message Expiration*](MessageExpiration.html) settings are used. *Selective Consumer*s make a single channel act like multiple [*Datatype Channel*](DatatypeChannel.html)s. If different message types have distinct selection values, each consumer that is specialized for a particular type will only receive messages of that type. This approach facilitates sending many message types using a small number of channels, which can be beneficial in an enterprise that requires more channels than their messaging system can support. *Competing, Selective Consumers* ... Read the entire pattern in the book [Enterprise Integration Patterns](/books1.html) **Related patterns:** [*Competing Consumers*](CompetingConsumers.html), [*Content-Based Router*](ContentBasedRouter.html), [*Correlation Identifier*](CorrelationIdentifier.html), [*Datatype Channel*](DatatypeChannel.html), [*Durable Subscriber*](DurableSubscription.html), [*Event-Driven Consumer*](EventDrivenConsumer.html), [*Message Filter*](Filter.html), [*Guaranteed Delivery*](GuaranteedMessaging.html), [*Invalid Message Channel*](InvalidMessageChannel.html), [*Message*](Message.html), [*Message Channel*](MessageChannel.html), [*Message Dispatcher*](MessageDispatcher.html), [*Message Expiration*](MessageExpiration.html), [*Messaging*](Messaging.html), [*Point-to-Point Channel*](PointToPointChannel.html), [*Polling Consumer*](PollingConsumer.html), [*Publish-Subscribe Channel*](PublishSubscribeChannel.html), [*Request-Reply*](RequestReply.html), [*Transactional Client*](TransactionalClient.html) --- ## Integration Pattern Language [Message Construct.](MessageConstructionIntro.html) [Message](Message.html) [Command Message](CommandMessage.html) [Document Message](DocumentMessage.html) [Event Message](EventMessage.html) [Request-Reply](RequestReply.html) [Return Address](ReturnAddress.html) [Correlation Identifier](CorrelationIdentifier.html) [Message Sequence](MessageSequence.html) [Message Expiration](MessageExpiration.html) [Format Indicator](FormatIndicator.html) [Message Routing](MessageRoutingIntro.html) [Pipes-and-Filters](PipesAndFilters.html) [Message Router](MessageRouter.html) [Content-based Router](ContentBasedRouter.html) [Message Filter](Filter.html) [Dynamic Router](DynamicRouter.html) [Recipient List](RecipientList.html) [Splitter](Sequencer.html) [Aggregator](Aggregator.html) [Resequencer](Resequencer.html) [Composed Msg. Processor](DistributionAggregate.html) [Scatter-Gather](BroadcastAggregate.html) [Routing Slip](RoutingTable.html) [Process Manager](ProcessManager.html) [Message Broker](MessageBroker.html) [Message Transformation](MessageTransformationIntro.html) [Message Translator](MessageTranslator.html) [Envelope Wrapper](EnvelopeWrapper.html) [Content Enricher](DataEnricher.html) [Content Filter](ContentFilter.html) [Claim Check](StoreInLibrary.html) [Normalizer](Normalizer.html) [Canonical Data Model](CanonicalDataModel.html) [Messaging Endpoints](MessagingEndpointsIntro.html) [Message Endpoint](MessageEndpoint.html) [Messaging Gateway](MessagingGateway.html) [Messaging Mapper](MessagingMapper.html) [Transactional Client](TransactionalClient.html) [Polling Consumer](PollingConsumer.html) [Event-driven Consumer](EventDrivenConsumer.html) [Competing Consumers](CompetingConsumers.html) [Message Dispatcher](MessageDispatcher.html) [Selective Consumer](MessageSelector.html) [Durable Subscriber](DurableSubscription.html) [Idempotent Receiver](IdempotentReceiver.html) [Service Activator](MessagingAdapter.html) [Messaging Channels](MessagingChannelsIntro.html) [Message Channel](MessageChannel.html) [Point-to-Point Channel](PointToPointChannel.html) [Publish-Subscr. Channel](PublishSubscribeChannel.html) [Datatype Channel](DatatypeChannel.html) [Invalid Message Channel](InvalidMessageChannel.html) [Dead Letter Channel](DeadLetterChannel.html) [Guaranteed Delivery](GuaranteedMessaging.html) [Channel Adapter](ChannelAdapter.html) [Messaging Bridge](MessagingBridge.html) [Message Bus](MessageBus.html) [Systems Mgmt.](SystemManagementIntro.html) [Control Bus](ControlBus.html) [Detour](Detour.html) [Wire Tap](WireTap.html) [Message History](MessageHistory.html) [Message Store](MessageStore.html) [Smart Proxy](SmartProxy.html) [Test Message](TestMessage.html) [Channel Purger](ChannelPurger.html)