protected void Push(string exchange, string routingKey, object payload, IBasicProperties properties = null) { if (String.IsNullOrWhiteSpace(exchange)) { throw new ArgumentNullException(nameof(exchange)); } if (String.IsNullOrWhiteSpace(routingKey)) { throw new ArgumentNullException(nameof(routingKey)); } ConnectionPool.Execute(ConnectionUri, (IModel channel) => { var props = properties ?? GetDefaultProperties(channel); var payloadJson = payload != null ? payload.ToJson() : String.Empty; var messageBytes = TextEncoding.GetBytes(payloadJson); channel.BasicPublish(exchange, routingKey, props, messageBytes); }); }
protected void Execute(Action <IModel> action) { ConnectionPool.Execute(ConnectionUri, action); }