public static Create ( |
||
attach | ||
return |
public static AmqpLinkSettings Create(Attach attach)
{
AmqpLinkSettings settings = new AmqpLinkSettings();
settings.LinkName = attach.LinkName;
settings.Role = !attach.Role.Value;
settings.Source = attach.Source;
settings.Target = attach.Target;
settings.SndSettleMode = attach.SndSettleMode;
settings.RcvSettleMode = attach.RcvSettleMode;
settings.MaxMessageSize = attach.MaxMessageSize;
settings.DesiredCapabilities = attach.DesiredCapabilities;
settings.OfferedCapabilities = attach.OfferedCapabilities;
settings.Properties = attach.Properties;
if (settings.Role.Value)
{
settings.TotalLinkCredit = AmqpConstants.DefaultLinkCredit;
settings.AutoSendFlow = true;
}
else
{
settings.InitialDeliveryCount = 0;
}
return settings;
}
protected bool TryCreateRemoteLink(Attach attach, out AmqpLink link) { link = null; if (this.linkFactory == null) { return(false); } AmqpLinkSettings linkSettings = AmqpLinkSettings.Create(attach); Exception error = null; try { link = this.LinkFactory.CreateLink(this, linkSettings); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } AmqpException amqpException = exception as AmqpException; if (amqpException != null && amqpException.Error != null && (amqpException.Error.Condition.Equals(AmqpErrorCode.ResourceLimitExceeded) || amqpException.Error.Condition.Equals(AmqpErrorCode.ResourceLocked))) { // out of handle or link name exists throw; } AmqpTrace.Provider.AmqpLogError(this, "CreateLink", exception.Message); // detach requires a handle so the error link has to be attached first link = new ErrorLink(this, linkSettings); error = exception; } link.RemoteHandle = attach.Handle; this.linksByRemoteHandle.Add(attach.Handle.Value, link); if (error != null) { link.SafeClose(error); return(false); } return(true); }