Merge pull request #478 from LnL7/publish-persistent

make messages persistent
This commit is contained in:
Graham Christensen 2020-04-30 15:42:20 -04:00 committed by GitHub
commit 3b6947cd20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View file

@ -194,13 +194,19 @@ async fn action_deliver(
let key = msg.routing_key.take().unwrap_or_else(|| "".to_owned());
log::debug!("action publish {}", exch);
let mut props = BasicProperties::default().with_delivery_mode(2); // persistent.
if let Some(s) = msg.content_type {
props = props.with_content_type(s.into());
}
let _confirmaton = chan
.basic_publish(
&exch,
&key,
BasicPublishOptions::default(),
msg.content,
BasicProperties::default(),
props,
)
.await?
.await?;

View file

@ -82,6 +82,7 @@ impl<'a> NotificationReceiver for ChannelNotificationReceiver<'a> {
let props = BasicProperties {
content_type: msg.content_type,
delivery_mode: Some(2), // persistent
..Default::default()
};
self.channel

View file

@ -104,6 +104,7 @@ impl<T: SimpleWorker + Send> amqp::Consumer for Worker<T> {
let props = BasicProperties {
content_type: msg.content_type,
delivery_mode: Some(2), // persistent
..Default::default()
};
channel