// Constructor internal to prevent clients from creating an instance. internal MessageConsumer(Session session, ConsumerId id, ActiveMQDestination destination, String name, String selector, int prefetch, int maxPendingMessageCount, bool noLocal, bool browser, bool dispatchAsync) { if (destination == null) { throw new InvalidDestinationException("Consumer cannot receive on Null Destinations."); } this.session = session; this.redeliveryPolicy = this.session.Connection.RedeliveryPolicy; this.info = new ConsumerInfo(); this.info.ConsumerId = id; this.info.Destination = destination; this.info.SubscriptionName = name; this.info.Selector = selector; this.info.PrefetchSize = prefetch; this.info.MaximumPendingMessageLimit = maxPendingMessageCount; this.info.NoLocal = noLocal; this.info.Browser = browser; this.info.DispatchAsync = dispatchAsync; this.info.Retroactive = session.Retroactive; this.info.Exclusive = session.Exclusive; this.info.Priority = session.Priority; // If the destination contained a URI query, then use it to set public properties // on the ConsumerInfo if (destination.Options != null) { URISupport.SetProperties(this.info, destination.Options, "consumer."); } }
public MessageDispatch(ConsumerId consumerId, Destination destination, BytesMessage message, Int32 redeliveryCounter) { ConsumerId = consumerId; Destination = destination; Message = message; RedeliveryCounter = redeliveryCounter; }
internal virtual MessageConsumer DoCreateMessageConsumer( ConsumerId id, ActiveMQDestination destination, string name, string selector, int prefetch, int maxPending, bool noLocal) { return(new MessageConsumer(this, id, destination, name, selector, prefetch, maxPending, noLocal, false, this.DispatchAsync)); }
public IMessageConsumer CreateConsumer(IDestination destination, string selector, bool noLocal) { ConsumerInfo command = CreateConsumerInfo(destination, selector); command.NoLocal = noLocal; command.AcknowledgementMode = this.AcknowledgementMode; ConsumerId consumerId = command.ConsumerId; MessageConsumer consumer = null; try { consumer = new MessageConsumer(this, command, this.AcknowledgementMode); // lets register the consumer first in case we start dispatching messages immediately consumers[consumerId] = consumer; this.DoSend(command); return(consumer); } catch (Exception) { if (consumer != null) { consumer.Close(); } throw; } }
// Constructor internal to prevent clients from creating an instance. internal MessageConsumer(Session session, ConsumerId id, IDestination destination, String name, String selector, Int32 prefetch, Boolean noLocal) { if (destination == null) { throw new InvalidDestinationException("Consumer cannot receive on null Destinations."); } _session = session; RedeliveryPolicy = _session.Connection.RedeliveryPolicy; ConsumerInfo = new ConsumerInfo { ConsumerId = id, Destination = Destination.Transform(destination), SubscriptionName = name, Selector = selector, PrefetchSize = prefetch, MaximumPendingMessageLimit = session.Connection.PrefetchPolicy.MaximumPendingMessageLimit, NoLocal = noLocal, DispatchAsync = session.DispatchAsync, Retroactive = session.Retroactive, Exclusive = session.Exclusive, Priority = session.Priority, AckMode = session.AcknowledgementMode }; // Removed unused consumer. options (ConsumerInfo => "consumer.") // TODO: Implement settings? // Removed unused message consumer. options (this => "consumer.nms.") // TODO: Implement settings? }
public IMessageConsumer CreateDurableConsumer( ITopic destination, string name, string selector, bool noLocal) { ConsumerInfo command = CreateConsumerInfo(destination, selector); ConsumerId consumerId = command.ConsumerId; command.SubscriptionName = name; command.NoLocal = noLocal; try { MessageConsumer consumer = new MessageConsumer(this, command, acknowledgementMode); // lets register the consumer first in case we start dispatching messages immediately connection.AddConsumer(consumerId, consumer); connection.SyncRequest(command); consumers[consumerId] = consumer; return(consumer); } catch (Exception e) { connection.RemoveConsumer(consumerId); throw e; } }
public ConsumerState this[ConsumerId consumerId] { get { return(consumers[consumerId]); } }
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 override Response ProcessRemoveConsumer(ConsumerId id) { if (id != null) { SessionId sessionId = id.ParentId; if (sessionId != null) { ConnectionId connectionId = sessionId.ParentId; if (connectionId != null) { ConnectionState cs = null; if (connectionStates.TryGetValue(connectionId, out cs)) { SessionState ss = cs[sessionId]; if (ss != null) { ss.RemoveConsumer(id); } } } } } return(TRACKED_RESPONSE_MARKER); }
public ConsumerState this[ConsumerId id] { get { #if DEBUG try { #endif return(consumers[id]); #if DEBUG } catch (System.Collections.Generic.KeyNotFoundException ex) { // Useful for dignosing missing consumer ids string consumerList = string.Empty; foreach (ConsumerId consumerId in consumers.Keys) { consumerList += consumerId.ToString() + "\n"; } System.Diagnostics.Debug.Assert(false, string.Format("Consumer '{0}' did not exist in the consumers collection.\n\nConsumers:-\n{1}", id, consumerList)); throw ex; } #endif } }
public BrowsingMessageConsumer(QueueBrowser parent, Session session, ConsumerId id, ActiveMQDestination destination, String name, String selector, int prefetch, int maxPendingMessageCount, bool noLocal, bool browser, bool dispatchAsync) : base(session, id, destination, name, selector, prefetch, maxPendingMessageCount, noLocal, browser, dispatchAsync) { this.parent = parent; }
public ConsumerState removeConsumer(ConsumerId id) { ConsumerState ret = consumers[id]; consumers.Remove(id); return(ret); }
internal void addDispatcher(ConsumerId id, IDispatcher dispatcher) { if (!this.closing.Value) { this.dispatchers.Add(id, dispatcher); } }
internal void removeDispatcher(ConsumerId id) { if (!this.closing.Value) { this.dispatchers.Remove(id); } }
public IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector, bool noLocal) { if (destination == null) { throw new InvalidDestinationException("Cannot create a Consumer with a Null destination"); } ConsumerInfo command = CreateConsumerInfo(destination, selector); ConsumerId consumerId = command.ConsumerId; command.SubscriptionName = name; command.NoLocal = noLocal; MessageConsumer consumer = null; try { consumer = new MessageConsumer(this, command, this.AcknowledgementMode); // lets register the consumer first in case we start dispatching messages immediately consumers[consumerId] = consumer; this.DoSend(command); } catch (Exception) { if (consumer != null) { consumer.Close(); } throw; } return(consumer); }
public ConsumerState this[ConsumerId id] { get { ConsumerState consumerState = null; consumers.TryGetValue(id, out consumerState); #if DEBUG if (null == consumerState) { // Useful for dignosing missing consumer ids string consumerList = string.Empty; foreach (ConsumerId consumerId in consumers.Keys) { consumerList += consumerId.ToString() + "\n"; } System.Diagnostics.Debug.Assert(false, string.Format("Consumer '{0}' did not exist in the consumers collection.\n\nConsumers:-\n{1}", id, consumerList)); } #endif return(consumerState); } }
public ConsumerState removeConsumer(ConsumerId id) { ConsumerState ret = null; consumers.TryGetValue(id, out ret); consumers.Remove(id); return(ret); }
public void AddConsumer(MessageConsumer consumer) { ConsumerId id = consumer.ConsumerId; // Registered with Connection before we register at the broker. consumers[id] = consumer; connection.addDispatcher(id, this); }
public void DisposeOf(ConsumerId objectId) { Connection.RemoveDispatcher(objectId); if (!_closing) { _consumers.Remove(objectId); } }
public void DisposeOf(ConsumerId objectId) { connection.removeDispatcher(objectId); if (!this.closing) { consumers.Remove(objectId); } }
// // Write a object instance to data output stream // public override void LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut) { ConsumerId info = (ConsumerId)o; base.LooseMarshal(wireFormat, o, dataOut); LooseMarshalString(info.ConnectionId, dataOut); LooseMarshalLong(wireFormat, info.SessionId, dataOut); LooseMarshalLong(wireFormat, info.Value, dataOut); }
internal QueueBrowser(Session session, ConsumerId consumerId, ActiveMQDestination destination, string selector, bool dispatchAsync) { this.session = session; this.consumerId = consumerId; this.destination = destination; this.selector = selector; this.dispatchAsync = dispatchAsync; this.consumer = CreateConsumer(); }
internal NetTxMessageConsumer(Session session, ConsumerId id, ActiveMQDestination destination, string name, string selector, int prefetch, int maxPendingMessageCount, bool noLocal, bool browser, bool dispatchAsync) : base(session, id, destination, name, selector, prefetch, maxPendingMessageCount, noLocal, browser, dispatchAsync) { this.session = session as NetTxSession; this.transactionContext = session.TransactionContext as NetTxTransactionContext; }
private AdvisoryConsumer(Connection connection, ConsumerId consumerId) : base() { this.connection = connection; this.info = new ConsumerInfo(); this.info.ConsumerId = consumerId; this.info.Destination = AdvisorySupport.TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC; this.info.PrefetchSize = 1000; this.info.NoLocal = true; }
public ConsumerId GetNextConsumerId() { ConsumerId id = new ConsumerId(); id.ConnectionId = info.SessionId.ConnectionId; id.SessionId = info.SessionId.Value; id.Value = Interlocked.Increment(ref consumerCounter); return(id); }
// // Write a object instance to data output stream // public override void TightMarshal2(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut, BooleanStream bs) { base.TightMarshal2(wireFormat, o, dataOut, bs); ConsumerId info = (ConsumerId)o; TightMarshalString2(info.ConnectionId, dataOut, bs); TightMarshalLong2(wireFormat, info.SessionId, dataOut, bs); TightMarshalLong2(wireFormat, info.Value, dataOut, bs); }
// // Un-marshal an object instance from the data input stream // public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs) { base.TightUnmarshal(wireFormat, o, dataIn, bs); ConsumerId info = (ConsumerId)o; info.ConnectionId = TightUnmarshalString(dataIn, bs); info.SessionId = TightUnmarshalLong(wireFormat, dataIn, bs); info.Value = TightUnmarshalLong(wireFormat, dataIn, bs); }
// // Un-marshal an object instance from the data input stream // public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn) { base.LooseUnmarshal(wireFormat, o, dataIn); ConsumerId info = (ConsumerId)o; info.ConnectionId = LooseUnmarshalString(dataIn); info.SessionId = LooseUnmarshalLong(wireFormat, dataIn); info.Value = LooseUnmarshalLong(wireFormat, dataIn); }
public void DisposeOf(ConsumerId objectId, long lastDeliveredSequenceId) { connection.removeDispatcher(objectId); this.lastDeliveredSequenceId = Math.Min(this.lastDeliveredSequenceId, lastDeliveredSequenceId); if (!this.closing) { consumers.Remove(objectId); } }
private ConsumerId GetNextConsumerId() { var id = new ConsumerId { ConnectionId = _info.SessionId.ConnectionId, SessionId = _info.SessionId.Value, Value = Interlocked.Increment(ref _consumerCounter) }; return(id); }
public SessionId( ConsumerId consumerId ) { this.ConnectionId = consumerId.ConnectionId; this.value = consumerId.SessionId; }
public ConnectionId( ConsumerId consumerId ) { this.value = consumerId.ConnectionId; }
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; }