public override void Send(RabbitMqMessageWrapper message) { var messageToSend = new Message <byte[]>(message.Bytes); messageToSend.Properties.Headers.Add("forward_exchange", Configuration.ExchangeName); _bus.Publish(_stampExchange, string.Empty, false, false, messageToSend); }
public override void StartListening() { _rabbitConnection = _configuration.RabbitMqClusterMembers?.Count > 0 ? _configuration.ConnectionFactory.CreateConnection(_configuration.RabbitMqClusterMembers) : _configuration.ConnectionFactory.CreateConnection(); _publishModel = _rabbitConnection.CreateModel(); _receiveModel = _rabbitConnection.CreateModel(); _receiveModel.ExchangeDeclare(_configuration.ExchangeName, ExchangeType.Fanout, true); var queue = _configuration.QueueName == null ? _receiveModel.QueueDeclare() : _receiveModel.QueueDeclare(_configuration.QueueName, true, false, false, new Dictionary<string, object>()); _receiveModel.QueueBind(queue.QueueName, _configuration.ExchangeName, ""); var consumer = new EventingBasicConsumer(_receiveModel); consumer.Received += (sender, args) => { var message = new RabbitMqMessageWrapper { Bytes = args.Body, Id = Convert.ToUInt64(Encoding.UTF8.GetString((byte[]) args.BasicProperties.Headers[MessageIdHeader])) }; OnMessage(message); }; _receiveModel.BasicConsume(queue.QueueName, true, consumer); }
public override void Send(RabbitMqMessageWrapper message) { using (var channel = _bus.OpenPublishChannel()) { var messageToSend = new Message<RabbitMqMessageWrapper>(message); channel.Publish(_exchange, string.Empty, messageToSend); } }
protected override Task Send(IList <Message> messages) { var buffer = new RabbitMqMessageWrapper(messages) { Tcs = new TaskCompletionSource <object>() }; _sendingbuffer.Add(buffer); return(buffer.Tcs.Task); }
public override void Send(RabbitMqMessageWrapper message) { var properties = new BasicProperties { Headers = new Dictionary<string, object> { {MessageIdHeader, GetNewMessageId().ToString()} } }; _publishModel.BasicPublish(Configuration.ExchangeName, string.Empty, properties, message.Bytes); }
public override void Send(RabbitMqMessageWrapper message) { var properties = new BasicProperties { Headers = new Dictionary <string, object> { { "forward_exchange", Configuration.ExchangeName } } }; _publishModel.BasicPublish(Configuration.StampExchangeName, "", properties, message.Bytes); }
public override void Send(RabbitMqMessageWrapper message) { var properties = new BasicProperties { Headers = new Dictionary<string, object> { { "forward_exchange", Configuration.ExchangeName } } }; _publishModel.BasicPublish(Configuration.StampExchangeName, "", properties, message.Bytes); }
protected override Task Send(Message[] messages) { return Task.Factory.StartNew(msgs => { var messagesToSend = msgs as Message[]; messagesToSend.GroupBy(m => m.Source).ToList().ForEach(group => { var message = new RabbitMqMessageWrapper(group.Key, group.ToArray()); _rabbitConnection.Send(message); }); }, messages); }
public Task Send(RabbitMqMessageWrapper message) { try { if (_channel.IsOpen) { return Task.Factory.StartNew(() => _channel.BasicPublish(_rabbitMqExchangeName, message.Key, null, message.GetBytes())); } throw new Exception("RabbitMQ channel is not open."); } catch (Exception exception) { TaskCompletionSource<bool> completionSource = new TaskCompletionSource<bool>(); completionSource.SetException(exception); return completionSource.Task; } }
public override void StartListening() { _receiveexchange = _bus.ExchangeDeclare(Configuration.ExchangeName, ExchangeType.Fanout); _stampExchange = _bus.ExchangeDeclare(Configuration.StampExchangeName, "x-stamp"); _queue = Configuration.QueueName == null ? _bus.QueueDeclare() : _bus.QueueDeclare(Configuration.QueueName); _bus.Bind(_receiveexchange, _queue, "#"); _bus.Consume <byte[]>(_queue, (msg, messageReceivedInfo) => { var bytes = msg.Body; var message = new RabbitMqMessageWrapper { Bytes = bytes, Id = (ulong)Convert.ToInt64(msg.Properties.Headers["stamp"]) }; return(Task.Factory.StartNew(() => OnMessage(message))); }); }
public override void StartListening() { _receiveexchange = _bus.ExchangeDeclare(Configuration.ExchangeName, ExchangeType.Fanout); _stampExchange = _bus.ExchangeDeclare(Configuration.StampExchangeName, "x-stamp"); _queue = Configuration.QueueName == null ? _bus.QueueDeclare() : _bus.QueueDeclare(Configuration.QueueName); _bus.Bind( _receiveexchange, _queue, "#"); _bus.Consume<byte[]>(_queue, (msg, messageReceivedInfo) => { var bytes = msg.Body; var message = new RabbitMqMessageWrapper { Bytes = bytes, Id = (ulong) Convert.ToInt64(msg.Properties.Headers["stamp"]) }; return Task.Factory.StartNew(() => OnMessage(message)); }); }
protected override Task Send(IList<Message> messages) { var buffer = new RabbitMqMessageWrapper(messages) { Tcs = new TaskCompletionSource<object>() }; Sendingbuffer.Add(buffer); return buffer.Tcs.Task; }
protected void OnMessage(RabbitMqMessageWrapper message) { OnMessageRecieved.Invoke(message); }
public virtual void Send(RabbitMqMessageWrapper message) { throw new NotImplementedException("Implement the Send method in your Rabbit connection class."); }
public Task Send(string connectionId, string eventKey, object value) { var message = new RabbitMqMessageWrapper(connectionId, eventKey, value); return(Task.Factory.StartNew(SendMessage, message)); }
private void ForwardOnReceivedMessage( RabbitMqMessageWrapper message) { _messageIdentifierGenerator.LastSeenMessageIdentifier(message.Id); OnReceived(0, message.Id, message.ScaleoutMessage); }
protected override Task Send(IList<Message> messages) { return Task.Factory.StartNew(msgs => { try { var messagesToSend = msgs as IList<Message>; if (messagesToSend != null) { var message = new RabbitMqMessageWrapper( _messageIdentifierGenerator.GetNextMessageIdentifier(), messagesToSend); _rabbitConnectionBase.Send(message); } } catch { OnConnectionLost(); } }, messages); }
public override void Send(RabbitMqMessageWrapper message) { var messageToSend = new Message<byte[]>(message.Bytes); messageToSend.Properties.Headers.Add("forward_exchange", Configuration.ExchangeName); _bus.Publish(_stampExchange, string.Empty, false, false, messageToSend); }