本文整理汇总了C#中IModel.ExchangeBind方法的典型用法代码示例。如果您正苦于以下问题:C# IModel.ExchangeBind方法的具体用法?C# IModel.ExchangeBind怎么用?C# IModel.ExchangeBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IModel
的用法示例。
在下文中一共展示了IModel.ExchangeBind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupSubscription
public void SetupSubscription(IModel channel, Type type, string subscriberName)
{
if (type == typeof(IEvent))
{
// Make handlers for IEvent handle all events whether they extend IEvent or not
type = typeof(object);
}
SetupTypeSubscriptions(channel, type);
channel.ExchangeBind(subscriberName, ExchangeName(type), string.Empty);
}
示例2: SetupTypeSubscriptions
void SetupTypeSubscriptions(IModel channel, Type type)
{
if (type == typeof(Object) || IsTypeTopologyKnownConfigured(type))
{
return;
}
{
var typeToProcess = type;
CreateExchange(channel, ExchangeName(typeToProcess));
var baseType = typeToProcess.BaseType;
while (baseType != null)
{
CreateExchange(channel, ExchangeName(baseType));
channel.ExchangeBind(ExchangeName(baseType), ExchangeName(typeToProcess), string.Empty);
typeToProcess = baseType;
baseType = typeToProcess.BaseType;
}
}
foreach (var exchangeName in type.GetInterfaces().Select(ExchangeName))
{
CreateExchange(channel, exchangeName);
channel.ExchangeBind(exchangeName, ExchangeName(type), string.Empty);
}
MarkTypeConfigured(type);
}
示例3: EstablishSubscription
void EstablishSubscription(IModel model, Type subscription)
{
var eventName = GetEventName(subscription);
var exchange = UsingOneExchangePerMessageTypeRouting ? eventName : ExchangeName;
var routingKey = UsingOneExchangePerMessageTypeRouting ? "" : eventName;
var inputAddress = InputQueueAddress.TrimStart('@');
if (UsingOneExchangePerMessageTypeRouting)
{
log.Debug("Declaring fanout exchange for: {0}", exchange);
model.ExchangeDeclare(exchange, "fanout", true, false, null);
}
log.Info("Subscribing {0} to {1}", inputAddress, eventName);
if (InputQueueAddressIsExchange)
{
model.ExchangeBind(inputAddress, exchange, routingKey);
}
else
{
model.QueueBind(inputAddress, exchange, routingKey);
}
}
示例4: StartConnection
private void StartConnection()
{
try
{
var factory = GetConnectionFac();
factory.UseBackgroundThreadsForIO = true;
_Connection = factory.CreateConnection();
_Connection.ConnectionShutdown += ShutdownAmqp;
try { _Model = _Connection.CreateModel(); }
catch (Exception e)
{
ErrorHandler.Error("could not create model", e);
}
}
catch (Exception e)
{
ErrorHandler.Error("could not connect to Rabbit instance", e);
}
if (_Model != null)
{
_Model.ExchangeDeclare(this.ExchangeProperties.Name, this.ExchangeProperties.ExchangeType, this.ExchangeProperties.Durable, this.ExchangeProperties.AutoDelete, null);
foreach (ExchangeBinding exchangeBinding in this.ExchangeProperties.Bindings)
{
_Model.ExchangeBind(exchangeBinding.Destination, this.ExchangeProperties.Name, exchangeBinding.Topic);
}
_Model.ModelShutdown += OnModelShutdown;
this.Debug("apqp connection opened");
}
}
示例5: DeclareBindings
/// <summary>Declare the bindings.</summary>
/// <param name="channel">The channel.</param>
/// <param name="bindings">The bindings.</param>
private void DeclareBindings(IModel channel, params Binding[] bindings)
{
foreach (var binding in bindings)
{
Logger.Debug(m => m("Binding destination [{0} ({1})] to exchange [{2}] with routing key [{3}]", binding.Destination, binding.BindingDestinationType, binding.Exchange, binding.RoutingKey));
if (binding.IsDestinationQueue())
{
if (!this.IsDeclaringImplicitQueueBinding(binding))
{
channel.QueueBind(binding.Destination, binding.Exchange, binding.RoutingKey, binding.Arguments);
}
}
else
{
channel.ExchangeBind(binding.Destination, binding.Exchange, binding.RoutingKey, binding.Arguments);
}
}
}