public void SendToQueue(IModel channel, Subscription subscription) { var byteMessage = ProtoSerialization.SerializeAndGetBytes(subscription); channel.BasicPublish(exchange: brokerSubscriptionsQueueName, routingKey: "", basicProperties: null, body: byteMessage); Logger.Log($"Sent subscriptions: {subscription}"); }
private static void SendToQueue(IModel channel, IBasicProperties properties, Publication publication) { var bytes = ProtoSerialization.SerializeAndGetBytes(publication); channel.BasicPublish(exchange: "", routingKey: exchangeAgent, basicProperties: properties, body: bytes); Logger.Log($" [*] Sent publication: {publication} |"); }
public void ForwardSubscription(Subscription subscription) { if (subscription.ForwardNumber == (Constants.NumberOfBrokers - 1)) { return; } string forwardId = GetNextBrokerId(subscription); var s = new Subscription { Id = subscription.Id, SenderId = $"B{brokerId}", Filter = subscription.Filter, ForwardNumber = subscription.ForwardNumber + 1 }; var brokerSubscriptionsQueueName = $"Subscriptions_{forwardId}"; using (var connection = factory.CreateConnection()) { using (var channel = connection.CreateModel()) { channel.ExchangeDeclare(exchange: brokerSubscriptionsQueueName, type: "direct"); var byteMessage = ProtoSerialization.SerializeAndGetBytes(s); channel.BasicPublish(exchange: brokerSubscriptionsQueueName, routingKey: "", basicProperties: null, body: byteMessage); Logger.Log($" [*] Forwarded subscription: {s}"); } } }
private static void SendForwardsPublication(Publication publication, string receiverId) { var body = ProtoSerialization.SerializeAndGetBytes(publication); ChanelPublicationsForward.BasicPublish(exchange: forwardPublicationsExchange, routingKey: receiverId, basicProperties: null, body: body); Logger.Log($" [x] Sent forward publication to {receiverId} : {publication}"); }
private static void SendToConsumerQueue(IModel channel, Publication publication, string receiverId) { Logger.Log($" [*] Send to consumer", true); Logger.Log($" [*] Send to consumer {publication}"); var bytes = ProtoSerialization.SerializeAndGetBytes(publication); channel.QueueDeclare(queue: receiverId, durable: true, exclusive: false, autoDelete: false, arguments: null); var properties = channel.CreateBasicProperties(); properties.Persistent = true; channel.BasicPublish(exchange: "", routingKey: receiverId, basicProperties: properties, body: bytes); }