public CopyTo ( IBasicProperties basicProperties ) : void | ||
basicProperties | IBasicProperties | |
리턴 | void |
// -------------------------------- publish --------------------------------------------- public virtual Task PublishAsync( IExchange exchange, string routingKey, bool mandatory, bool immediate, MessageProperties messageProperties, byte[] body) { Preconditions.CheckNotNull(exchange, "exchange"); Preconditions.CheckShortString(routingKey, "routingKey"); Preconditions.CheckNotNull(messageProperties, "messageProperties"); Preconditions.CheckNotNull(body, "body"); var task = clientCommandDispatcher.Invoke(x => { var properties = x.CreateBasicProperties(); messageProperties.CopyTo(properties); return(publisherConfirms.PublishWithConfirm(x, m => m.BasicPublish(exchange.Name, routingKey, mandatory, immediate, properties, body))); }).Unwrap(); logger.DebugWrite("Published to exchange: '{0}', routing key: '{1}', correlationId: '{2}'", exchange.Name, routingKey, messageProperties.CorrelationId); return(task); }
public virtual void Publish(IExchange exchange, string routingKey, MessageProperties properties, byte[] messageBody, Action <IAdvancedPublishConfiguration> configure) { Preconditions.CheckNotNull(exchange, "exchange"); Preconditions.CheckNotNull(routingKey, "routingKey"); Preconditions.CheckNotNull(properties, "properties"); Preconditions.CheckNotNull(messageBody, "messageBody"); Preconditions.CheckNotNull(configure, "configure"); if (disposed) { throw new EasyNetQException("PublishChannel is already disposed"); } if (!advancedBus.Connection.IsConnected) { throw new EasyNetQException("Publish failed. No rabbit server connected."); } try { var configuration = new AdvancedPublishConfiguration(); configure(configuration); if (publisherConfirms != null) { if (configuration.SuccessCallback == null || configuration.FailureCallback == null) { throw new EasyNetQException("When pulisher confirms are on, you must supply success and failure callbacks in the publish configuration"); } publisherConfirms.RegisterCallbacks(channel, configuration.SuccessCallback, configuration.FailureCallback); } var defaultProperties = channel.CreateBasicProperties(); properties.CopyTo(defaultProperties); exchange.Visit(new TopologyBuilder(channel)); channel.BasicPublish( exchange.Name, // exchange routingKey, // routingKey defaultProperties, // basicProperties messageBody); // body advancedBus.Logger.DebugWrite("Published to exchange: '{0}', routing key: '{1}', correlationId: '{2}'", exchange.Name, routingKey, defaultProperties.CorrelationId); } catch (OperationInterruptedException exception) { throw new EasyNetQException("Publish Failed: '{0}'", exception.Message); } catch (System.IO.IOException exception) { throw new EasyNetQException("Publish Failed: '{0}'", exception.Message); } }
public void Publish(IExchange exchange, string routingKey, MessageProperties properties, byte[] messageBody) { if (exchange == null) { throw new ArgumentNullException("exchange"); } if (routingKey == null) { throw new ArgumentNullException("routingKey"); } if (properties == null) { throw new ArgumentNullException("properties"); } if (messageBody == null) { throw new ArgumentNullException("messageBody"); } if (disposed) { throw new EasyNetQException("PublishChannel is already disposed"); } if (!advancedBus.Connection.IsConnected) { throw new EasyNetQException("Publish failed. No rabbit server connected."); } try { var defaultProperties = channel.CreateBasicProperties(); properties.CopyTo(defaultProperties); exchange.Visit(new TopologyBuilder(channel)); channel.BasicPublish( exchange.Name, // exchange routingKey, // routingKey defaultProperties, // basicProperties messageBody); // body advancedBus.Logger.DebugWrite("Published to exchange: '{0}', routing key: '{1}', correlationId: '{2}'", exchange.Name, routingKey, defaultProperties.CorrelationId); } catch (OperationInterruptedException exception) { throw new EasyNetQException("Publish Failed: '{0}'", exception.Message); } catch (System.IO.IOException exception) { throw new EasyNetQException("Publish Failed: '{0}'", exception.Message); } }