Skip to content

Commit

Permalink
Merge pull request #74 from step-finance/deser-fix
Browse files Browse the repository at this point in the history
don't log whole message
  • Loading branch information
thesoftwarejedi authored Sep 19, 2024
2 parents 913d924 + f395941 commit d04f8fd
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions crates/rabbitmq/src/consumer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! An AMQP consumer configured from a [`QueueType`]

use std::{io::Seek, marker::PhantomData};
use std::marker::PhantomData;

use futures_util::StreamExt;
use lapin::{acker::Acker, options::BasicNackOptions, Connection};
Expand Down Expand Up @@ -72,20 +72,13 @@ where
None => return Ok(None),
};

let mut data_cursor: std::io::Cursor<Vec<u8>> = std::io::Cursor::new(delivery.data);
let deser_result = deserialize(&mut data_cursor);
let data_cursor: std::io::Cursor<Vec<u8>> = std::io::Cursor::new(delivery.data);
let deser_result = deserialize(data_cursor);
if deser_result.is_err() {
delivery.acker.nack(BasicNackOptions::default()).await?;
if let Err(e) = data_cursor.seek(std::io::SeekFrom::Start(0)) {
log::error!(
"Failed to rewind cursor during Failed to deserialize message: {}",
e
);
}
log::error!(
"Failed to deserialize message: {:?}. Message is {:?}",
deser_result,
String::from_utf8(data_cursor.into_inner()),
"FATAL REAL BAD ERROR - Failed to deserialize message, will DLQ: {:?}.",
deser_result
);
}
deser_result
Expand Down

0 comments on commit d04f8fd

Please sign in to comment.