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); }
private MessageConsumer CreateConsumer() { this.browseDone.Value = false; BrowsingMessageConsumer consumer = null; try { consumer = new BrowsingMessageConsumer( this, session, this.consumerId, this.destination, null, this.selector, this.session.Connection.PrefetchPolicy.QueueBrowserPrefetch, this.session.Connection.PrefetchPolicy.MaximumPendingMessageLimit, false, true, this.dispatchAsync); this.session.AddConsumer(consumer); this.session.Connection.SyncRequest(consumer.ConsumerInfo); if (this.session.Connection.IsStarted) { consumer.Start(); } } catch (Exception) { if (consumer != null) { this.session.RemoveConsumer(consumer.ConsumerId); consumer.Close(); } throw; } return(consumer); }
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; } }
public async System.Threading.Tasks.Task DispatchAsync(MessageDispatch dispatch) { try { MessageConsumer consumer = null; lock (this.consumers.SyncRoot) { if (this.consumers.Contains(dispatch.ConsumerId)) { consumer = this.consumers[dispatch.ConsumerId] as MessageConsumer; } } // If the consumer is not available, just ignore the message. // Otherwise, dispatch the message to the consumer. if (consumer != null) { await consumer.Dispatch_Async(dispatch).Await(); } } catch (Exception ex) { Tracer.DebugFormat("Caught Exception While Dispatching: {0}", ex.Message); } }
public void Dispatch(MessageDispatch dispatch) { try { MessageConsumer consumer = null; lock (this.consumers.SyncRoot) { if (this.consumers.Contains(dispatch.ConsumerId)) { consumer = this.consumers[dispatch.ConsumerId] as MessageConsumer; } } // If the consumer is not available, just ignore the message. // Otherwise, dispatch the message to the consumer. if (consumer != null) { consumer.Dispatch(dispatch); } } catch (Exception ex) { Tracer.DebugFormat("Caught Exception While Dispatching: {0}", ex.Message); } }
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); }
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(); }
public void Reset() { if (consumer != null) { DestroyConsumer(); } consumer = CreateConsumerAsync().GetAsyncResult(); }
public void Reset() { if (consumer != null) { DestroyConsumer(); } consumer = CreateConsumer(); }
public void RemoveConsumer(MessageConsumer consumer) { connection.RemoveDispatcher(consumer.ConsumerId); if (!this.closing) { consumers.Remove(consumer.ConsumerId); } connection.RemoveDispatcher(consumer); }
private static void ClearMessages(object value) { MessageConsumer consumer = value as MessageConsumer; if (Tracer.IsDebugEnabled) { Tracer.Debug("Performing Async Clear of In Progress Messages on Consumer: " + consumer.ConsumerId); } consumer.ClearMessagesInProgress(); }
public bool DispatchMessage(ConsumerId consumerId, Message message) { bool dispatched = false; MessageConsumer consumer = (MessageConsumer)consumers[consumerId]; if (consumer != null) { consumer.Dispatch((ActiveMQMessage)message); dispatched = true; } return(dispatched); }
public IEnumerator GetEnumerator() { CheckClosed(); lock (myLock) { if (this.consumer == null) { this.consumer = CreateConsumer(); } } return(this); }
public IMessageConsumer CreateConsumer(IDestination destination, string selector, bool noLocal) { if (destination == null) { throw new InvalidDestinationException("Cannot create a Consumer with a Null destination"); } ActiveMQDestination dest = ActiveMQDestination.Transform(destination); int prefetchSize = this.Connection.PrefetchPolicy.DurableTopicPrefetch; if (dest.IsTopic) { prefetchSize = this.connection.PrefetchPolicy.TopicPrefetch; } else if (dest.IsQueue) { prefetchSize = this.connection.PrefetchPolicy.QueuePrefetch; } MessageConsumer consumer = null; try { consumer = DoCreateMessageConsumer(GetNextConsumerId(), dest, null, selector, prefetchSize, this.connection.PrefetchPolicy.MaximumPendingMessageLimit, noLocal); consumer.ConsumerTransformer = this.ConsumerTransformer; this.AddConsumer(consumer); this.Connection.SyncRequest(consumer.ConsumerInfo); if (this.Connection.IsStarted) { consumer.Start(); } } catch (Exception) { if (consumer != null) { this.RemoveConsumer(consumer); consumer.Close(); } throw; } return(consumer); }
public void AddConsumer(MessageConsumer consumer) { if (!this.closing) { ConsumerId id = consumer.ConsumerId; // Registered with Connection before we register at the broker. using (consumersLock.Lock()) { consumers[id] = consumer; } connection.AddDispatcher(id, this); } }
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"); } if (IsIndividualAcknowledge) { throw new NMSException("Cannot create a durable consumer for a session that is using " + "Individual Acknowledgement mode."); } ActiveMQDestination dest = ActiveMQDestination.Transform(destination); MessageConsumer consumer = null; try { consumer = DoCreateMessageConsumer(GetNextConsumerId(), dest, name, selector, this.connection.PrefetchPolicy.DurableTopicPrefetch, this.connection.PrefetchPolicy.MaximumPendingMessageLimit, noLocal); consumer.ConsumerTransformer = this.ConsumerTransformer; this.AddConsumer(consumer); this.Connection.SyncRequest(consumer.ConsumerInfo); if (this.Connection.IsStarted) { consumer.Start(); } } catch (Exception) { if (consumer != null) { this.RemoveConsumer(consumer); consumer.Close(); } throw; } return(consumer); }
private void DestroyConsumer() { if (consumer == null) { return; } try { consumer.Close(); consumer = null; } catch (NMSException e) { Tracer.Debug(e.StackTrace.ToString()); } }
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; command.PrefetchSize = this.connection.PrefetchPolicy.DurableTopicPrefetch; MessageConsumer consumer = null; // Registered with Connection before we register at the broker. connection.addDispatcher(consumerId, this); try { consumer = new MessageConsumer(this, command); // lets register the consumer first in case we start dispatching messages immediately consumers[consumerId] = consumer; if (this.Started) { consumer.Start(); } this.connection.SyncRequest(command); } catch (Exception) { if (consumer != null) { consumer.Close(); } throw; } return(consumer); }
private MessageConsumer CreateConsumer() { this.browseDone.Value = false; BrowsingMessageConsumer consumer = null; if (this.session.Connection.PrefetchPolicy.QueueBrowserPrefetch == 0) { Tracer.Warn("Attempted to create a Queue Browser with Zero sized prefetch buffer."); throw new NMSException("Cannot create a Queue Browser with Zero sized prefetch buffer"); } try { consumer = new BrowsingMessageConsumer( this, session, this.consumerId, this.destination, null, this.selector, this.session.Connection.PrefetchPolicy.QueueBrowserPrefetch, this.session.Connection.PrefetchPolicy.MaximumPendingMessageLimit, false, true, this.dispatchAsync); this.session.AddConsumer(consumer); this.session.Connection.SyncRequest(consumer.ConsumerInfo); if (this.session.Connection.IsStarted) { consumer.Start(); } } catch (Exception) { if (consumer != null) { this.session.RemoveConsumer(consumer); consumer.Close(); } throw; } return(consumer); }
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"); } ActiveMQDestination dest = ActiveMQDestination.Transform(destination); MessageConsumer consumer = null; try { consumer = new MessageConsumer(this, GetNextConsumerId(), dest, name, selector, this.connection.PrefetchPolicy.DurableTopicPrefetch, this.connection.PrefetchPolicy.MaximumPendingMessageLimit, noLocal, false, this.connection.DispatchAsync); consumer.ConsumerTransformer = this.ConsumerTransformer; this.AddConsumer(consumer); this.Connection.SyncRequest(consumer.ConsumerInfo); if (this.Connection.IsStarted) { consumer.Start(); } } catch (Exception) { if (consumer != null) { this.RemoveConsumer(consumer.ConsumerId); consumer.Close(); } throw; } return(consumer); }
private void DestroyConsumer() { if (consumer == null) { return; } try { if (session.IsTransacted && session.TransactionContext.InLocalTransaction) { session.Commit(); } consumer.Close(); consumer = null; } catch (NMSException e) { Tracer.Debug(e.StackTrace.ToString()); } }
public MessageConsumerSynchronization(MessageConsumer consumer) { this.consumer = consumer; }
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"); } ActiveMQDestination dest = ActiveMQDestination.Transform(destination); MessageConsumer consumer = null; try { consumer = new MessageConsumer(this, GetNextConsumerId(), dest, name, selector, this.connection.PrefetchPolicy.DurableTopicPrefetch, this.connection.PrefetchPolicy.MaximumPendingMessageLimit, noLocal, false, this.connection.DispatchAsync); consumer.ConsumerTransformer = this.ConsumerTransformer; this.AddConsumer(consumer); this.Connection.SyncRequest(consumer.ConsumerInfo); if(this.Connection.IsStarted) { consumer.Start(); } } catch(Exception) { if(consumer != null) { this.RemoveConsumer(consumer.ConsumerId); consumer.Close(); } throw; } return consumer; }
public void AddConsumer(MessageConsumer consumer) { if(!this.closing) { ConsumerId id = consumer.ConsumerId; // Registered with Connection before we register at the broker. consumers[id] = consumer; connection.addDispatcher(id, this); } }
private void DestroyConsumer() { if(consumer == null) { return; } try { if(session.IsTransacted && session.TransactionContext.InLocalTransaction) { session.Commit(); } consumer.Close(); consumer = null; } catch(NMSException e) { Tracer.Debug(e.StackTrace.ToString()); } }
public IEnumerator GetEnumerator() { CheckClosed(); lock(myLock) { if(this.consumer == null) { this.consumer = CreateConsumer(); } } return this; }
public ConsumerCloseSynchronization(MessageConsumer consumer) { this.consumer = consumer; }
public void Reset() { if(consumer != null) { DestroyConsumer(); } consumer = CreateConsumer(); }
public NmsConsumer(ISession session, MessageConsumer consumer) { this.session = session; this.consumer = consumer; }
private MessageConsumer CreateConsumer() { this.browseDone.Value = false; BrowsingMessageConsumer consumer = null; try { consumer = new BrowsingMessageConsumer( this, session, this.consumerId, this.destination, null, this.selector, this.session.Connection.PrefetchPolicy.QueueBrowserPrefetch, this.session.Connection.PrefetchPolicy.MaximumPendingMessageLimit, false, true, this.dispatchAsync); this.session.AddConsumer(consumer); this.session.Connection.SyncRequest(consumer.ConsumerInfo); if(this.session.Connection.IsStarted) { consumer.Start(); } } catch(Exception) { if(consumer != null) { this.session.RemoveConsumer(consumer.ConsumerId); consumer.Close(); } throw; } return consumer; }
public MessageConsumerSynchronization(MessageConsumer consumer, Message message) { this.message = message; this.consumer = consumer; }