2 releases
0.1.1 | May 8, 2019 |
---|---|
0.1.0 | May 1, 2019 |
#1404 in Development tools
9KB
105 lines
SQSListen, a simple listener for AWS SQS queue.
It allows you to set listener to your AWS SQS queue which will ask for the available messages in the queue and call the passed handler when the message received. Once message received and processed (does not matter if handler returns error or not) the message is removed from the queue.
Installation
[dependencies]
sqslisten = "0.1"
Usage
use sqslisten::{ReceiveMessageRequest, Region, SQSListen};
use std::{thread, time};
fn main() {
let mut sqs_listener = SQSListen::new(Region::UsEast1);
let handle = sqs_listener.listen(
ReceiveMessageRequest {
queue_url: "<queue_url>".to_string(),
..ReceiveMessageRequest::default()
},
|msg, err| {
match msg {
Some(message) => println!("Message received: {:?}", message),
None => {}
}
match err {
Some(error) => println!("Error received: {:?}", error),
None => {}
}
return Ok(());
},
);
let ten_seconds = time::Duration::from_millis(100000);
thread::sleep(ten_seconds);
handle.stop();
}
Dependencies
~19MB
~361K SLoC