public void OnDelivery(AmqpLink link, Delivery delivery) { var message = AnnotatedMessage.Decode(delivery.PayloadBuffer); var queue = linkNameToQueue[link.Name]; queue.Enqueue(message); link.SetDeliveryTerminalState(delivery, new Accepted()); }
public bool CanAttachLink(AmqpLink newLink, Attach attach) { var queueName = ""; if (attach.IsReceiver) queueName = attach.Source.Address.ToLowerInvariant(); if (!attach.IsReceiver) queueName = attach.Target.Address.ToLowerInvariant(); var queue = queues.GetOrAdd(queueName, x => new ConcurrentQueue(0, logWriter)); return true; }
public void OnLinkAttached(AmqpLink link) { if (link.IsReceiverLink) { link.SetLinkCredit(25); linkNameToQueue[link.Name] = queues[link.TargetAddress.ToLowerInvariant()]; } if (link.IsSenderLink) { var queue = queues[link.SourceAddress.ToLowerInvariant()]; linkNameToQueue[link.Name] = queue; linkToConsumer[link] = new LinkConsumer(queue, link); } }
public LinkConsumer(ConcurrentQueue queue, AmqpLink link) : base(queue) { this.link = link; this.link.ReceivedFlow += LinkReceivedFlow; }
public void OnLinkAttached(AmqpLink link) { }
public void OnDelivery(AmqpLink link, Delivery delivery) { }
public bool CanAttachLink(AmqpLink newLink, Attach attach) { return true; }
internal void NotifyUnsettledIncomingDelivery(AmqpLink link, Delivery delivery) { incomingUnsettledMap.Add(delivery); }
public bool CanAttachLink(AmqpLink newLink, Attach attach) { throw new NotImplementedException(); }
private void InterceptAttachFrame(Attach attach) { if (!State.CanReceiveFrames()) throw new AmqpException(ErrorCode.IllegalState, $"Received Attach frame but session state is {State.ToString()}."); if (State == SessionStateEnum.DISCARDING) return; if (attach.Handle > sessionMaxHandle) throw new AmqpException(ErrorCode.NotAllowed, $"Cannot allocate more handles. The maximum number of handles is {sessionMaxHandle}."); // is this for an existing locally attached frame? for (uint i = 0; i < localLinks.Length; i++) { var existingLink = localLinks[i]; if (existingLink != null && existingLink.State == LinkStateEnum.ATTACH_SENT && string.Compare(existingLink.Name, attach.Name, true) == 0) { AttachRemoteLink(attach, existingLink); // Link is expecting an attach frame existingLink.HandleLinkFrame(attach); return; // done } } // must be a new inbound attach var nextLocalHandle = localLinks.GetFirstNullIndexOrAdd(); // reuse existing handle, or just grab the next one var isLocalLinkReceiver = !attach.IsReceiver; var newLink = new AmqpLink(this, attach.Name, nextLocalHandle, isLocalLinkReceiver, false, attach.Handle); if (!Connection.Container.CanAttachLink(newLink, attach)) throw new AmqpException(ErrorCode.PreconditionFailed, "Cannot Attach Link"); var index = localLinks[nextLocalHandle] = newLink; AttachRemoteLink(attach, newLink); newLink.HandleLinkFrame(attach); }
private void AttachRemoteLink(Attach attach, AmqpLink link) { if (remoteLinks[attach.Handle] != null) { throw new AmqpException(ErrorCode.HandleInUse, $"The handle '{attach.Handle}' is already allocated for '{remoteLinks[attach.Handle].Name}'"); } remoteLinks[attach.Handle] = link; }
internal void NotifyUnsettledIncomingDelivery(AmqpLink link, Delivery delivery) { incomingUnsettledMap.Add(delivery); }
public void UnmapLink(AmqpLink link, bool destoryLink) { trace.Debug("Detached Link: LOC({0}) <-> RMT({1})", link.LocalHandle, link.RemoteHandle); localLinks[link.LocalHandle] = null; remoteLinks[link.RemoteHandle] = null; if (destoryLink) trace.Debug("Destroyed Link: LOC({0}) <-> RMT({1})", link.LocalHandle, link.RemoteHandle); }