Skip to main content

send_delay_ex

Function send_delay_ex 

Source
pub async fn send_delay_ex(
    topic: &str,
    msgid: String,
    data: HashMap<String, String>,
    duration: Duration,
) -> Result<(), ZimqError>
Expand description

Publishes a delayed message with a custom message ID to the specified topic. If a delayed message with the same ID already exists and has not been consumed yet, this method will return ZimqError::DuplicatedMessageError to prevent duplicates.

§Arguments

  • topic - Message topic
  • msgid - Message ID
  • data - Message data
  • duration - Duration

§Errors

  • ZimqError

§Examples

let mut data = HashMap::new();
data.insert("id".to_string(), "123456".to_string());
let msgid = "msgid123456".to_string();
let result = zimq::send_delay_ex("user",msgid,data,Duration::from_secs(20)).await;
if let Err(ZimqError::DuplicatedMessageError(msg) ) = result {
    println!("DuplicatedMessageError: {}", msg);
 }