sqslisten

Crates.iosqslisten
lib.rssqslisten
version0.1.1
sourcesrc
created_at2019-05-01 15:04:02.221332
updated_at2019-05-08 10:37:43.389142
descriptionSQSListen, 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.
homepagehttps://github.com/andrewnester/sqslisten
repositoryhttps://github.com/andrewnester/sqslisten
max_upload_size
id131395
size9,344
Andrew Nester (andrewnester)

documentation

README

SQSListen, a simple listener for AWS SQS queue.

Build Status

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();
}
Commit count: 9

cargo fmt