mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-15 12:15:02 +01:00
route topics
This commit is contained in:
parent
58de7f1e2d
commit
43d0ce05dc
10 changed files with 98 additions and 49 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use haesli_core::{
|
||||
amqp_todo,
|
||||
connection::Channel,
|
||||
|
|
@ -29,16 +31,17 @@ pub fn publish(channel_handle: Channel, message: Message) -> Result<()> {
|
|||
.get(exchange.as_str())
|
||||
.ok_or(ChannelException::NotFound)?;
|
||||
|
||||
let queue = routing::route_message(exchange, &message.routing.routing_key)
|
||||
.ok_or(ChannelException::NotFound)?;
|
||||
|
||||
queue
|
||||
.event_send
|
||||
.try_send(QueueEvent::PublishMessage(message))
|
||||
.map_err(|err| {
|
||||
error!(?err, "Failed to send message to queue event queue");
|
||||
ConException::InternalError
|
||||
})?;
|
||||
let queues = routing::route_message(exchange, &message.routing.routing_key)
|
||||
.ok_or(ChannelException::NotFound)?; // todo this isn't really correct but the tests pass ✔️
|
||||
|
||||
for queue in queues {
|
||||
queue
|
||||
.event_send
|
||||
.try_send(QueueEvent::PublishMessage(Arc::clone(&message)))
|
||||
.map_err(|err| {
|
||||
error!(?err, "Failed to send message to queue event queue");
|
||||
ConException::InternalError
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue