예제 #1
0
 private void OnRabbitReceived(RabbitMqMessage message, string consumer)
 {
     if (RabbitReceived != null)
     {
         RabbitReceived(message, consumer);
     }
 }
예제 #2
0
        private void OnRabbitReceived(RabbitMqMessage message, string consumer)
        {
            Console.WriteLine("RabbitMq: Data Received.");

            if (RabbitReceived != null)
            {
                RabbitReceived(message, consumer);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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.");
            }
        }
예제 #5
0
 public RabbitMqEventArgs(RabbitMqMessage message)
 {
     this.Message = message;
 }
예제 #6
0
 private void MessageReceiver_RabbitReceived(RabbitMqMessage message, string consumer)
 {
     OnRabbitReceived(message, consumer);
 }