January 2019
Intermediate to advanced
520 pages
14h 32m
English
Let's add the process_message method, which processes incoming Delivery items:
impl<T: QueueHandler> QueueActor<T> { fn process_message( &self, item: Delivery, _: &mut Context<Self>, ) -> Result<Option<(ShortString, T::Outgoing)>, Error> { let corr_id = item .properties .correlation_id() .to_owned() .ok_or_else(|| format_err!("Message has no address for the response"))?; let incoming = serde_json::from_slice(&item.data)?; let outgoing = self.handler.handle(&corr_id, incoming)?; if let Some(outgoing) = outgoing { Ok(Some((corr_id, outgoing))) } else { Ok(None) } } }
First, we have to get a unique ID associated with a message. If you remember, we used the UUID in this case. We stored it in the correlation ID field of the message. ...
Read now
Unlock full access