|
1 |
| -//! This is a port of the nodejs Redis Simple Message Queue package. It is a 1-to-1 conversion using async. |
| 1 | +//! This is a port of the nodejs Redis Simple Message Queue package. |
| 2 | +//! It is a 1-to-1 conversion using async. |
2 | 3 | //!
|
3 | 4 | //! ```rust,no_run
|
4 | 5 | //! use rsmq_async::{Rsmq, RsmqError};
|
|
18 | 19 | //! Main object documentation in: <a href="struct.Rsmq.html">Rsmq<a/>
|
19 | 20 | //!
|
20 | 21 | //! ## Realtime
|
21 |
| -//! When [initializing](#initialize) RSMQ you can enable the realtime PUBLISH for new messages. On every new message that gets sent to RSQM via `sendMessage` a Redis PUBLISH will be issued to `{rsmq.ns}:rt:{qname}`. |
| 22 | +//! |
| 23 | +//! When [initializing](#initialize) RSMQ you can enable the realtime PUBLISH for |
| 24 | +//! new messages. On every new message that gets sent to RSQM via `sendMessage` a |
| 25 | +//! Redis PUBLISH will be issued to `{rsmq.ns}:rt:{qname}`. |
22 | 26 | //!
|
23 | 27 | //! Example for RSMQ with default settings:
|
24 | 28 | //!
|
|
27 | 31 | //! * The following Redis command will be issued: `PUBLISH rsmq:rt:testQueue 6`
|
28 | 32 | //!
|
29 | 33 | //! ### How to use the realtime option
|
30 |
| -//! Besides the PUBLISH when a new message is sent to RSMQ nothing else will happen. Your app could use the Redis SUBSCRIBE command to be notified of new messages and issue a `receiveMessage` then. However make sure not to listen with multiple workers for new messages with SUBSCRIBE to prevent multiple simultaneous `receiveMessage` calls. |
| 34 | +//! |
| 35 | +//! Besides the PUBLISH when a new message is sent to RSMQ nothing else will happen. |
| 36 | +//! Your app could use the Redis SUBSCRIBE command to be notified of new messages |
| 37 | +//! and issue a `receiveMessage` then. However make sure not to listen with multiple |
| 38 | +//! workers for new messages with SUBSCRIBE to prevent multiple simultaneous |
| 39 | +//! `receiveMessage` calls. |
31 | 40 | //!
|
32 | 41 | //! ## Guarantees
|
33 | 42 | //!
|
34 |
| -//! If you want to implement "at least one delivery" guarantee, you need to receive the messages using "receive_message" and then, once the message is successfully processed, delete it with "delete_message". |
| 43 | +//! If you want to implement "at least one delivery" guarantee, you need to receive |
| 44 | +//! the messages using "receive_message" and then, once the message is successfully |
| 45 | +//! processed, delete it with "delete_message". |
| 46 | +//! |
| 47 | +//! ```rust,no_run |
| 48 | +//! use rsmq_async::Rsmq; |
35 | 49 | //!
|
36 |
| -//! If you want to implement "one or less delivery" guarantee, you can use the "pop_message" method. Be aware that you may loose (delete without processing) messages in that case. |
| 50 | +//! # #[tokio::main] //You can use Tokio or Async-std |
| 51 | +//! # async fn main() { |
| 52 | +//! let mut rsmq = Rsmq::new(Default::default()) |
| 53 | +//! .await |
| 54 | +//! .expect("connection failed"); |
| 55 | +//! |
| 56 | +//! rsmq.create_queue("myqueue", None, None, None) |
| 57 | +//! .await |
| 58 | +//! .expect("failed to create queue"); |
| 59 | +//! |
| 60 | +//! rsmq.send_message("myqueue", "testmessage", None) |
| 61 | +//! .await |
| 62 | +//! .expect("failed to send message"); |
| 63 | +//! |
| 64 | +//! let message = rsmq |
| 65 | +//! .receive_message("myqueue", None) |
| 66 | +//! .await |
| 67 | +//! .expect("cannot receive message"); |
| 68 | +//! |
| 69 | +//! if let Some(message) = message { |
| 70 | +//! rsmq.delete_message("myqueue", &message.id).await; |
| 71 | +//! } |
| 72 | +//! # } |
| 73 | +//! ``` |
| 74 | +//! ## Executor compatibility |
| 75 | +//! |
| 76 | +//! Since version 0.16 redis dependency supports tokio and async_std executors. |
| 77 | +//! By default it will guess what you are using when creating the connection. |
| 78 | +//! You can check [redis](https://github.com/mitsuhiko/redis-rs/blob/master/Cargo.toml) |
| 79 | +//! `Cargo.tolm` for the flags `async-std-comp` and `tokio-comp` |
37 | 80 | //!
|
38 |
| -
|
39 | 81 |
|
40 | 82 | #![forbid(unsafe_code)]
|
41 | 83 |
|
|
0 commit comments