public bool Process(Envelope envelope)
 {
     var json = Encoding.UTF8.GetString(envelope.Body);
     var message = JsonConvert.DeserializeObject<FakeMessage1>(json);
     message.Username = "******";
     envelope.Body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message));
     _beforeFilter1Ran = true;
     return true;
 }
 public bool Process(Envelope envelope)
 {
     Console.WriteLine("Inside before filter 1");
     var json = Encoding.UTF8.GetString(envelope.Body);
     var message = JsonConvert.DeserializeObject<FilterMessage>(json);
     message.FilterModifiedValue = "modified by consumer";
     envelope.Body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message));
     return true;
 }
        public bool Process(Envelope envelope)
        {
            var json = Encoding.UTF8.GetString(envelope.Body);
            var message = JsonConvert.DeserializeObject<FilterMessage>(json);

            Console.WriteLine("Inside before filter 2");

            if (message.ConsumerFilterFail)
            {
                return false;
            }
            
            return true;
        }
        public bool Process(Envelope envelope)
        {
            using (var messageMemoryStream = new MemoryStream(envelope.Body))
            using (var compressedMessageMemoryStream = new MemoryStream())
            {
                using (var gzipStream = new GZipStream(compressedMessageMemoryStream, CompressionMode.Compress))
                {
                    MemoryStreamUtilities.CopyTo(messageMemoryStream, gzipStream);
                }

                envelope.Body = compressedMessageMemoryStream.ToArray();
            }
            return true;
        }
 public bool Process(Envelope envelope)
 {
     return false;
 }
 public bool Process(Envelope envelope)
 {
     _afterFilter2Ran = true;
     return true;
 }
 public bool Process(Envelope envelope)
 {
     _beforeFilter2Ran = true;
     return true;
 }
 public bool Process(Envelope envelope)
 {
     Console.WriteLine("Inside after filter 2");
     return true;
 }
 public bool Process(Envelope envelope)
 {
     Console.WriteLine("Filter1");
     return true;
 }
        public void SendBytes(string endPoint, byte[] packet, Dictionary<string, string> headers)
        {
            lock (_lock)
            {
                IBasicProperties basicProperties = _model.CreateBasicProperties();
                basicProperties.SetPersistent(true);

                var messageHeaders = GetHeaders(typeof(byte[]), headers, endPoint, "ByteStream");

                var envelope = new Envelope
                {
                    Body = packet,
                    Headers = messageHeaders
                };

                basicProperties.Headers = envelope.Headers;
                basicProperties.MessageId = basicProperties.Headers["MessageId"].ToString(); // keep track of retries

                Retry.Do(() => _model.BasicPublish(string.Empty, endPoint, basicProperties, envelope.Body),
                         ex => RetryConnection(),
                         new TimeSpan(0, 0, 0, 6), 10);
            }
        }
        private void DoPublish(Type type, byte[] message, Dictionary<string, string> headers)
        {
            lock (_lock)
            {
                IBasicProperties basicProperties = _model.CreateBasicProperties();

                var messageHeaders = GetHeaders(type, headers, _transportSettings.QueueName, "Publish");

                var envelope = new Envelope
                {
                    Body = message,
                    Headers = messageHeaders
                };

                basicProperties.Headers = envelope.Headers;
                basicProperties.MessageId = basicProperties.Headers["MessageId"].ToString(); // keep track of retries

                basicProperties.SetPersistent(true);
                var exchangeName = ConfigureExchange(type.FullName.Replace(".", string.Empty));

                Retry.Do(() => _model.BasicPublish(exchangeName, _transportSettings.QueueName, basicProperties, envelope.Body),
                    ex => RetryConnection(),
                    new TimeSpan(0, 0, 0, 6), 10);
            }
        }