readme: added example for message versioning

This commit is contained in:
2005 2024-11-14 19:33:14 +01:00
parent ee1bb1abdf
commit 6b26c1a90c

View file

@ -47,13 +47,30 @@ bunbun-worker = { git = "https://git.4o1x5.dev/4o1x5/bunbun-worker", branch = "m
## Usage ## Usage
Here is a basic implementation of an RPC job in bunbun-worker ### Message versioning
In this crate message versioning is done by including `v1.0.0` or such on the end of the queue name, instead of including it in the headers of a message. This reduces the amount of redelivered messages.
The following example will send a job to a queue named `emailjob-v1.0.0`.
```rust
let result = client
.rpc_call::<EmailJob>(
EmailJob {
send_to: "someone".into(),
contents: "something".into(),
},
BasicCallOptions::default("emailjob")
.timeout(Duration::from_secs(3))
.message_version("v1.0.0")
)
.await
.unwrap();
```
# Limitations # Limitations
1. Currently some `unwrap()`'s are called inside the code and may results in panics (not in the job-runner). 1. Currently some `unwrap()`'s are called inside the code and may results in panics (not in the job-runner).
2. No settings, and very limited API 2. limited API
3. The rabbitmq RPC logic is very basic with no message-versioning (aside using different queue names (eg service-class-v1.0.0) )
# Bugs department # Bugs department