public AmqpConsumer(AmqpSession amqpSession, NmsConsumerInfo info) { session = amqpSession; this.info = info; messages = new LinkedList <InboundMessageDispatch>(); }
public async Task CreateConsumer(NmsConsumerInfo consumerInfo) { AmqpConsumer amqpConsumer = new AmqpConsumer(this, consumerInfo); await amqpConsumer.Attach(); consumers.TryAdd(consumerInfo.Id, amqpConsumer); }
private string GetSharedDurableSubLinkName(string subscriptionName, NmsConsumerInfo consumerInfo) { IDestination topic = consumerInfo.Destination; string selector = consumerInfo.Selector; SubDetails subDetails = null; if (sharedDurableSubs.ContainsKey(subscriptionName)) { subDetails = sharedDurableSubs[subscriptionName]; if (subDetails.Matches(topic, selector)) { subDetails.AddSubscriber(consumerInfo); } else { throw new NMSException("Subscription details dont match existing subscriber."); } } else { subDetails = new SubDetails(topic, selector, consumerInfo); } sharedDurableSubs.Add(subscriptionName, subDetails); int count = subDetails.TotalSubscriberCount(); return(GetDurableSubscriptionLinkName(subscriptionName, consumerInfo.IsExplicitClientId, count)); }
protected NmsMessageConsumer(NmsConsumerId consumerId, NmsSession session, IDestination destination, string name, string selector, bool noLocal) { Session = session; acknowledgementMode = session.AcknowledgementMode; if (destination.IsTemporary) { session.Connection.CheckConsumeFromTemporaryDestination((NmsTemporaryDestination)destination); } Info = new NmsConsumerInfo(consumerId) { Destination = destination, Selector = selector, NoLocal = noLocal, SubscriptionName = name, LocalMessageExpiry = Session.Connection.ConnectionInfo.LocalMessageExpiry, IsDurable = IsDurableSubscription }; deliveryTask = new MessageDeliveryTask(this); Session.Connection.CreateResource(Info).ConfigureAwait(false).GetAwaiter().GetResult(); Session.Add(this); if (Session.IsStarted) { Start(); } }
public string ReserveNextSubscriptionLinkName(string subscriptionName, NmsConsumerInfo consumerInfo) { ValidateSubscriptionName(subscriptionName); if (consumerInfo == null) { throw new ArgumentException("Consumer info must not be null."); } if (consumerInfo.IsShared) { if (consumerInfo.IsDurable) { return(GetSharedDurableSubLinkName(subscriptionName, consumerInfo)); } else { return(GetSharedVolatileSubLinkName(subscriptionName, consumerInfo)); } } else if (consumerInfo.IsDurable) { RegisterExclusiveDurableSub(subscriptionName); return(subscriptionName); } else { throw new IllegalStateException( "Non-shared non-durable sub link naming is not handled by the tracker."); } }
public void TestCreateFromConsumerId() { var consumerInfo = new NmsConsumerInfo(firstId); Assert.AreSame(firstId, consumerInfo.Id); Assert.AreSame(firstId.SessionId, consumerInfo.SessionId); Assert.IsFalse(string.IsNullOrEmpty(consumerInfo.ToString())); }
public void AddSubscriber(NmsConsumerInfo info) { if (info == null) { throw new ArgumentException("Consumer info must not be null"); } totalSubscriberCount++; subscribers.Add(info); }
public void TestEqualsCode() { var first = new NmsConsumerInfo(firstId); var second = new NmsConsumerInfo(secondId); Assert.AreEqual(first, first); Assert.AreEqual(second, second); Assert.AreNotEqual(first, second); }
public void TestHashCode() { var first = new NmsConsumerInfo(firstId); var second = new NmsConsumerInfo(secondId); Assert.AreEqual(first.GetHashCode(), first.GetHashCode()); Assert.AreEqual(second.GetHashCode(), second.GetHashCode()); Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode()); }
public void ConsumerRemoved(NmsConsumerInfo consumerInfo) { string subscriptionName = consumerInfo.SubscriptionName; if (!string.IsNullOrEmpty(subscriptionName)) { if (consumerInfo.IsShared) { if (consumerInfo.IsDurable) { if (sharedDurableSubs.ContainsKey(subscriptionName)) { SubDetails subDetails = sharedDurableSubs[subscriptionName]; subDetails.RemoveSubscriber(consumerInfo); int count = subDetails.ActiveSubscribers(); if (count < 1) { sharedDurableSubs.Remove(subscriptionName); } } } else { if (sharedVolatileSubs.ContainsKey(subscriptionName)) { SubDetails subDetails = sharedVolatileSubs[subscriptionName]; subDetails.RemoveSubscriber(consumerInfo); int count = subDetails.ActiveSubscribers(); if (count < 1) { sharedVolatileSubs.Remove(subscriptionName); } } } } else if (consumerInfo.IsDurable) { exclusiveDurableSubs.Remove(subscriptionName); } } }
private String GetSharedVolatileSubLinkName(string subscriptionName, NmsConsumerInfo consumerInfo) { IDestination topic = consumerInfo.Destination; string selector = consumerInfo.Selector; SubDetails subDetails = null; if (sharedVolatileSubs.ContainsKey(subscriptionName)) { subDetails = sharedVolatileSubs[subscriptionName]; if (subDetails.Matches(topic, selector)) { subDetails.AddSubscriber(consumerInfo); } else { throw new NMSException("Subscription details dont match existing subscriber"); } } else { subDetails = new SubDetails(topic, selector, consumerInfo); } sharedVolatileSubs.Add(subscriptionName, subDetails); string receiverLinkName = subscriptionName + SUB_NAME_DELIMITER; int count = subDetails.TotalSubscriberCount(); if (consumerInfo.IsExplicitClientId) { receiverLinkName += "volatile" + count; } else { receiverLinkName += "global-volatile" + count; } return(receiverLinkName); }
protected NmsMessageConsumer(NmsConsumerId consumerId, NmsSession session, IDestination destination, string name, string selector, bool noLocal) { Session = session; acknowledgementMode = session.AcknowledgementMode; if (destination.IsTemporary) { session.Connection.CheckConsumeFromTemporaryDestination((NmsTemporaryDestination)destination); } Info = new NmsConsumerInfo(consumerId) { Destination = destination, Selector = selector, NoLocal = noLocal, IsExplicitClientId = Session.Connection.ConnectionInfo.IsExplicitClientId, SubscriptionName = name, IsShared = IsSharedSubscription, IsDurable = IsDurableSubscription, IsBrowser = IsBrowser, LocalMessageExpiry = Session.Connection.ConnectionInfo.LocalMessageExpiry }; deliveryTask = new MessageDeliveryTask(this); }
public void RemoveSubscriber(NmsConsumerInfo info) { subscribers.Remove(info); }
public SubDetails(IDestination topic, string selector, NmsConsumerInfo info) { this.topic = topic ?? throw new ArgumentException("Topic destination must not be null"); this.selector = selector; AddSubscriber(info); }
public InboundMessageDispatch ReceiveMessage(NmsConsumerInfo consumerInfo, TimeSpan timeout) { throw new NotImplementedException(); }