private void OnRabbitReceived(RabbitMqMessage message, string consumer) { if (RabbitReceived != null) { RabbitReceived(message, consumer); } }
private void OnRabbitReceived(RabbitMqMessage message, string consumer) { Console.WriteLine("RabbitMq: Data Received."); if (RabbitReceived != null) { RabbitReceived(message, consumer); } }
public override void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body) { try { string message = Encoding.UTF8.GetString(body); RabbitMqMessage messageobject = Newtonsoft.Json.JsonConvert.DeserializeObject <RabbitMqMessage>(message); OnRabbitReceived(messageobject, messageobject.Sender); } catch (Exception e) { Console.WriteLine("RabbitMQ: " + e.Message); } _channel.BasicAck(deliveryTag, false); }
public void Send(string exchange, RabbitMqMessage message) { if (Connected) { var channel = connection.CreateModel(); var properties = channel.CreateBasicProperties(); properties.Persistent = false; message.Sender = _serviceName; string data = Newtonsoft.Json.JsonConvert.SerializeObject(message); byte[] messagebuffer = Encoding.Default.GetBytes(data); channel.BasicPublish(exchange, "key", properties, messagebuffer); Console.WriteLine("RabbitMq: Data Transmitted."); } else { Console.WriteLine("RABBITMQ - Can't send message, not connected."); } }
public RabbitMqEventArgs(RabbitMqMessage message) { this.Message = message; }
private void MessageReceiver_RabbitReceived(RabbitMqMessage message, string consumer) { OnRabbitReceived(message, consumer); }