예제 #1
0
        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);
            });
        }
예제 #2
0
 protected void Execute(Action <IModel> action)
 {
     ConnectionPool.Execute(ConnectionUri, action);
 }