本文整理汇总了C#中IChannel.DeclareExchange方法的典型用法代码示例。如果您正苦于以下问题:C# IChannel.DeclareExchange方法的具体用法?C# IChannel.DeclareExchange怎么用?C# IChannel.DeclareExchange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IChannel
的用法示例。
在下文中一共展示了IChannel.DeclareExchange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public override void Init()
{
// Ensure that the base init method is called. It establishes a connection with the broker.
base.Init();
connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
_connection = new AMQConnection(connectionInfo);
_channel = _connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 500, 300);
_logger.Info("Starting...");
_logger.Info("Exchange name is '" + _exchangeName + "'...");
// Register this to listen for exceptions on the test connection.
_exceptionDelegate = new ExceptionListenerDelegate(OnException);
_connection.ExceptionListener += _exceptionDelegate;
// Declare a new headers exchange with the name of the test service.
_channel.DeclareExchange(_exchangeName, ExchangeClassConstants.HEADERS);
// Create a non-durable, temporary (aka auto-delete), exclusive queue.
string queueName = _channel.GenerateUniqueName();
_channel.DeclareQueue(queueName, false, true, true);
// Bind the queue to the new headers exchange, setting up some header patterns for the exchange to match.
_channel.Bind(queueName, _exchangeName, null, CreatePatternAsFieldTable());
// Create a test consumer to consume messages from the test exchange.
_consumer = _channel.CreateConsumerBuilder(queueName)
.WithPrefetchLow(100)
.WithPrefetchHigh(500)
.WithNoLocal(false) // make sure we get our own messages
.Create();
// Register this to listen for messages on the consumer.
_msgRecDelegate = new MessageReceivedDelegate(OnMessage);
_consumer.OnMessage += _msgRecDelegate;
// Clear the most recent message and exception.
_lastException = null;
_lastMessage = null;
_publisher = _channel.CreatePublisherBuilder()
.WithExchangeName(_exchangeName)
.WithMandatory(true)
.Create();
_publisher.DeliveryMode = DeliveryMode.NonPersistent;
// Start all channel
_connection.Start();
}