public void TestCommand() { ConsumerId value1 = new ConsumerId(); value1.ConnectionId = "abc"; value1.SessionId = 123; value1.Value = 456; ConsumerId value2 = new ConsumerId(); value2.ConnectionId = "abc"; value2.SessionId = 123; value2.Value = 456; ConsumerId value3 = new ConsumerId(); value3.ConnectionId = "abc"; value3.SessionId = 123; value3.Value = 457; Assert.AreEqual(value1, value2, "value1 and value2 should be equal"); Assert.AreEqual(value1.GetHashCode(), value2.GetHashCode(), "value1 and value2 hash codes should be equal"); Assert.IsTrue(!value1.Equals(value3), "value1 and value3 should not be equal"); Assert.IsTrue(!value3.Equals(value2), "value3 and value2 should not be equal"); // now lets test an IDictionary IDictionary dictionary = new Hashtable(); dictionary[value1] = value3; // now lets lookup with a copy object actual = dictionary[value2]; Assert.AreEqual(value3, actual, "Should have found item in Map using value2 as a key"); }
public virtual bool Equals(ConsumerId that) { if (! Equals(this.ConnectionId, that.ConnectionId)) return false; if (! Equals(this.SessionId, that.SessionId)) return false; if (! Equals(this.Value, that.Value)) return false; return true; }
public virtual bool Equals(ConsumerId that) { if (!Equals(this.ConnectionId, that.ConnectionId)) { return(false); } if (!Equals(this.SessionId, that.SessionId)) { return(false); } if (!Equals(this.Value, that.Value)) { return(false); } return(true); }
protected virtual ConsumerInfo CreateConsumerInfo(IDestination destination, string selector) { ConsumerInfo answer = new ConsumerInfo(); ConsumerId id = new ConsumerId(); id.ConnectionId = info.SessionId.ConnectionId; id.SessionId = info.SessionId.Value; lock (this) { id.Value = ++consumerCounter; } answer.ConsumerId = id; answer.Destination = ActiveMQDestination.Transform(destination); answer.Selector = selector; answer.PrefetchSize = prefetchSize; answer.Priority = priority; answer.Exclusive = exclusive; answer.DispatchAsync = dispatchAsync; answer.Retroactive = retroactive; // If the destination contained a URI query, then use it to set public properties // on the ConsumerInfo ActiveMQDestination amqDestination = destination as ActiveMQDestination; if (amqDestination != null && amqDestination.Options != null) { Util.URISupport.SetProperties(answer, amqDestination.Options, "consumer."); } return answer; }
public void DisposeOf(ConsumerId objectId) { consumers.Remove(objectId); connection.RemoveConsumer(objectId); connection.DisposeOf(objectId); }
public static ConsumerId ToConsumerId(string text) { if (text == null) { return null; } ConsumerId answer = new ConsumerId(); int idx = text.LastIndexOf(':'); if (idx >= 0) { answer.Value = Int32.Parse(text.Substring(idx + 1)); text = text.Substring(0, idx); idx = text.LastIndexOf(':'); if (idx >= 0) { answer.SessionId = Int32.Parse(text.Substring(idx + 1)); text = text.Substring(0, idx); } } answer.ConnectionId = text; return answer; }
public static string ToStomp(ConsumerId id) { return id.ConnectionId + ":" + id.SessionId + ":" + id.Value; }
/// <summary> /// Remove a consumer /// </summary> /// <param name="consumerId">A ConsumerId</param> public void RemoveConsumer(ConsumerId consumerId) { consumers[consumerId] = null; }
/// <summary> /// Register a new consumer /// </summary> /// <param name="consumerId">A ConsumerId</param> /// <param name="consumer">A MessageConsumer</param> public void AddConsumer(ConsumerId consumerId, MessageConsumer consumer) { consumers[consumerId] = consumer; }