more things

This commit is contained in:
nora 2022-03-04 23:05:50 +01:00
parent 5d127eceee
commit b6355f5e35
11 changed files with 129 additions and 122 deletions

View file

@ -1,7 +1,7 @@
use crate::Result;
use amqp_core::{
amqp_todo,
connection::{Channel, QueuedMethod},
connection::{Channel, ConnectionEvent},
error::ChannelException,
message::Message,
methods::{BasicPublish, Method},
@ -31,19 +31,24 @@ pub async fn publish(channel_handle: Channel, message: Message) -> Result<()> {
// consuming is hard, but this should work *for now*
let consumers = queue.consumers.lock();
if let Some(consumer) = consumers.first() {
let method = Method::BasicPublish(BasicPublish {
let method = Box::new(Method::BasicPublish(BasicPublish {
reserved_1: 0,
exchange: routing.exchange.clone(),
routing_key: routing.routing_key.clone(),
mandatory: false,
immediate: false,
});
}));
consumer.channel.queue_method(QueuedMethod::WithContent(
method,
message.header.clone(),
message.content.clone(),
));
consumer
.channel
.event_sender
.try_send(ConnectionEvent::MethodContent(
consumer.channel.num,
method,
message.header.clone(),
message.content.clone(),
))
.unwrap();
}
}