The Recipient List example didn’t demonstrate how the PriceQuote replies are assimilated by the MountaineeringSuppliesOrderProcessor. To correlate PriceQuote replies to the original RequestForQuotation we need to use the unique rfqId that has been passed along with each message:
orderProcessor ! RequestForQuotation("123", ...) ... recipient ! RequestPriceQuote(rfq.rfqId, ...) ... sender ! PriceQuote(rpq.rfqId, ...)
The previous example from Recipient List is extended here to include an Aggregator, which tracks the fulfillment of all requested price quotes. First note the new message types:
case class PriceQuoteFulFilled(priceQuote: PriceQuote) case class RequiredPriceQuotesForFulfillment(rfqId: String, quotesRequested: Int) case class QuotationFulfillment(rfqId: String, quotesRequested: Int, priceQuotes: Seq[PriceQuote], requester: ActorRef)
. . .
The full text is now available as part of my book Reactive Enterprise with Actor Model on Safari Books Online.