--- url: "http://www.enterpriseintegrationpatterns.com/RequestReply.html" titulek: "Request-Reply - Enterprise Integration Patterns" h1: "" popis: "When an application sends a message, how can it get a response from the receiver?" jazyk: "en" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-15 15:34:04" znaku: 6253 slov: 604 kodovani: "utf-8" sha256: "6d79d9ec15c68a7547682feb84c4adaea407795c64a69c98b6fed273eb2cea5f" --- | | Request-Reply[Messaging Patterns](index.html) » [Message Construction](MessageConstructionIntro.html) | [Contents](toc.html)[⇐ Prev](EventMessage.html)[Next ⇒](ReturnAddress.html) | | --- | --- | --- | When two applications communicate via [*Messaging*](Messaging.html), the communication is one-way. The applications may want a two-way conversation. When an application sends a message, how can it get a response from the receiver? Send a pair of *Request-Reply* messages, each on its own channel. *Request-Reply* has two participants: 1. **Requestor** – Sends a request message and waits for a reply message. 2. **Replier** – Receives the request message and responds with a reply message. The request channel can be a [*Point-to-Point Channel*](PointToPointChannel.html) or a [*Publish-Subscribe Channel*](PublishSubscribeChannel.html). The difference is whether the request should be broadcast to all interested parties or should only be processed by a single consumer. The reply channel, on the other hand, is almost always point-to-point, because it usually makes no sense to broadcast replies–they should only be returned to the requestor. When a caller performs a [*Remote Procedure Invocation*](EncapsulatedSynchronousIntegration.html), the caller's thread must block while it waits for the response. With *Request-Reply*, the requestor has two approaches for receiving the reply: 1. **Synchronous Block** – A single thread in the caller sends the request message, blocks (as a [*Polling Consumer*](PollingConsumer.html) ) to wait for the reply message, then processes the reply. This is simple to implement, but if the requestor crashes, it will have difficulty re-establishing the blocked thread. The request thread awaiting the response implies that there is only one outstanding request, or that the reply channel for this request is private for this thread. 2. **Asynchronous Callback** – One thread in the caller sends the request message and sets up a callback for the reply. A separate thread listens for reply messages. When a reply message arrives, the reply thread invokes the appropriate callback, which re-establishes the caller's context and processes the reply. This approach enables multiple outstanding requests to share a single reply channel, and a single reply thread to process replies for multiple request threads. If the requestor crashes, it can recover by simply restarting the reply thread. An added complexity, however, is the callback mechanism that must re-establish the caller's context. ... Read the entire pattern in the book [Enterprise Integration Patterns](/books1.html) **Related patterns:** [*Command Message*](CommandMessage.html), [*Correlation Identifier*](CorrelationIdentifier.html), [*Document Message*](DocumentMessage.html), [*Remote Procedure Invocation*](EncapsulatedSynchronousIntegration.html), [*Event Message*](EventMessage.html), [*Guaranteed Delivery*](GuaranteedMessaging.html), [*Message*](Message.html), [*Message Channel*](MessageChannel.html), [*Message Sequence*](MessageSequence.html), [*Messaging*](Messaging.html), [*Point-to-Point Channel*](PointToPointChannel.html), [*Polling Consumer*](PollingConsumer.html), [*Publish-Subscribe Channel*](PublishSubscribeChannel.html), [*Return Address*](ReturnAddress.html) **Further reading:** - [Will the real asynchrony please stand up?](/ramblings/28_asynchrony.html) - [Can You Say "Synchronous Asymmetry or Asynchronous Symmetry"?](/ramblings/26_symmetry.html) - [Correlation and Conversations](/ramblings/09_correlation.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)