Summary description for ActiveMQDestination.
Inheritance: BaseDataStructure, IDestination
Exemplo n.º 1
0
        public override void Init()
        {
            base.Init();
            _producers = new LinkedList<IMessageProducer>();
            _consumers = new Hashtable();

            XmlNode nmsNode = this.DestinationDefinition.PropertiesXml.SelectSingleNode("nms");
            _nmsSettings = new NMSSettings(nmsNode);
            if (_nmsSettings != null)
            {
                ConnectionFactory connectionFactory = new ConnectionFactory(_nmsSettings.URI);

                log.Debug(string.Format("NMSAdapter Connected to URI {0}", _nmsSettings.URI));

                _connection = connectionFactory.CreateConnection();
                _connection.Start();
                _session = _connection.CreateSession(AcknowledgementMode.DupsOkAcknowledge);

                if (_nmsSettings.DESTINATION_TYPE.StartsWith(NMSSettings.QueueDestination))
                {
                    _destination = new ActiveMQQueue(_nmsSettings.Destination);
                    log.Debug(string.Format("NMSAdapter Connected to Queue {0}", _nmsSettings.Destination));
                }
                else if (_nmsSettings.DESTINATION_TYPE.StartsWith(NMSSettings.TopicDestination))
                {
                    _destination = new ActiveMQTopic(_nmsSettings.Destination);
                    log.Debug(string.Format("NMSAdapter Connected to Topic {0}", _nmsSettings.Destination));
                }
                else
                {
                    log.Debug(string.Format("Unknown Destination Type {0}", _nmsSettings.DESTINATION_TYPE));
                }
            }
        }
Exemplo n.º 2
0
        public MessageProducer(Session session, ProducerId id, ActiveMQDestination destination, TimeSpan requestTimeout)
        {
            this.session = session;
            this.RequestTimeout = requestTimeout;

            this.info = new ProducerInfo();
            this.info.ProducerId = id;
            this.info.Destination = destination;
            this.info.WindowSize = session.Connection.ProducerWindowSize;

            this.messageTransformation = session.Connection.MessageTransformation;

            // If the destination contained a URI query, then use it to set public
            // properties on the ProducerInfo
            if(destination != null && destination.Options != null)
            {
                URISupport.SetProperties(this.info, destination.Options, "producer.");
            }

            // Version Three and higher will send us a ProducerAck, but only if we
            // have a set producer window size.
            if(session.Connection.ProtocolVersion >= 3 && this.info.WindowSize > 0)
            {
                Tracer.Debug("MessageProducer created with a Window Size of: " + this.info.WindowSize);
                this.usage = new MemoryUsage(this.info.WindowSize);
            }
        }
Exemplo n.º 3
0
		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();
		}
Exemplo n.º 4
0
 public static ActiveMQTopic GetConsumerAdvisoryTopic(ActiveMQDestination destination)
 {
     if (destination.IsQueue)
     {
         return new ActiveMQTopic(QUEUE_CONSUMER_ADVISORY_TOPIC_PREFIX + destination.PhysicalName);
     }
     else
     {
         return new ActiveMQTopic(TOPIC_CONSUMER_ADVISORY_TOPIC_PREFIX + destination.PhysicalName);
     }
 }
Exemplo n.º 5
0
 public static ActiveMQTopic GetExpiredQueueMessageAdvisoryTopic(ActiveMQDestination destination)
 {
     String name = EXPIRED_QUEUE_MESSAGES_TOPIC_PREFIX + destination.PhysicalName;
     return new ActiveMQTopic(name);
 }
Exemplo n.º 6
0
        // 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.messageTransformation = this.session.Connection.MessageTransformation;

            if(session.Connection.MessagePrioritySupported)
            {
                this.unconsumedMessages = new SimplePriorityMessageDispatchChannel();
            }
            else
            {
                this.unconsumedMessages = new FifoMessageDispatchChannel();
            }

            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)
            {
                // Get options prefixed with "consumer.*"
                StringDictionary options = URISupport.GetProperties(destination.Options, "consumer.");
                // Extract out custom extension options "consumer.nms.*"
                StringDictionary customConsumerOptions = URISupport.ExtractProperties(options, "nms.");

                URISupport.SetProperties(this.info, options);
                URISupport.SetProperties(this, customConsumerOptions, "nms.");
            }
        }
Exemplo n.º 7
0
        public ActiveMQDestination[] GetCompositeDestinations()
        {
            if (IsComposite)
            {
                LinkedList<String> list = new LinkedList<String>();
                String[] composites = physicalName.Split(COMPOSITE_SEPARATOR.ToCharArray());
                foreach(String composite in composites)
                {
                    if (String.IsNullOrEmpty(composite.Trim()))
                    {
                        continue;
                    }
                    list.AddLast(composite.Trim());
                }
                ActiveMQDestination[] compositeDestinations = new ActiveMQDestination[list.Count];
                int counter = 0;
                foreach(String destination in list)
                {
                    compositeDestinations[counter++] = CreateDestination(destination);
                }

                return compositeDestinations;
            }

            return new ActiveMQDestination[0];
        }
Exemplo n.º 8
0
		/// <summary>
		/// Lets sort by name first then lets sort topics greater than queues
		/// </summary>
		/// <param name="that">another destination to compare against</param>
		/// <returns>1 if this is less than o else 0 if they are equal or -1 if this is less than o</returns>
		public int CompareTo(ActiveMQDestination that)
		{
			int answer = 0;
			if(physicalName != that.physicalName)
			{
				if(physicalName == null)
				{
					return -1;
				}
				else if(that.physicalName == null)
				{
					return 1;
				}
				answer = physicalName.CompareTo(that.physicalName);
			}

			if(answer == 0)
			{
				if(IsTopic)
				{
					if(that.IsQueue)
					{
						return 1;
					}
				}
				else
				{
					if(that.IsTopic)
					{
						return -1;
					}
				}
			}
			return answer;
		}
Exemplo n.º 9
0
		/// <summary>
		/// From a temporary destination find the clientId of the Connection that created it
		/// </summary>
		/// <param name="destination"></param>
		/// <returns>the clientId or null if not a temporary destination</returns>
		public static String GetClientId(ActiveMQDestination destination)
		{
			String answer = null;
			if(destination != null && destination.IsTemporary)
			{
				String name = destination.PhysicalName;
				int start = name.IndexOf(TEMP_PREFIX);
				if(start >= 0)
				{
					start += TEMP_PREFIX.Length;
					int stop = name.LastIndexOf(TEMP_POSTFIX);
					if(stop > start && stop < name.Length)
					{
						answer = name.Substring(start, stop);
					}
				}
			}
			return answer;
		}
Exemplo n.º 10
0
 public static ActiveMQTopic GetSlowConsumerAdvisoryTopic(ActiveMQDestination destination)
 {
     String name = SLOW_CONSUMER_TOPIC_PREFIX + destination.GetDestinationTypeAsString() + "."
             + destination.PhysicalName;
     return new ActiveMQTopic(name);
 }
Exemplo n.º 11
0
			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;
			}
Exemplo n.º 12
0
 public static bool IsFullAdvisoryTopic(ActiveMQDestination destination)
 {
     if (destination.IsComposite)
     {
         ActiveMQDestination[] compositeDestinations = destination.GetCompositeDestinations();
         for (int i = 0; i < compositeDestinations.Length; i++)
         {
             if (IsFullAdvisoryTopic(compositeDestinations[i]))
             {
                 return true;
             }
         }
         return false;
     }
     else
     {
         return destination.IsTopic && destination.PhysicalName.StartsWith(FULL_TOPIC_PREFIX);
     }
 }
Exemplo n.º 13
0
 public static bool IsConnectionAdvisoryTopic(ActiveMQDestination destination) {
     if (destination.IsComposite)
     {
         ActiveMQDestination[] compositeDestinations = destination.GetCompositeDestinations();
         for (int i = 0; i < compositeDestinations.Length; i++)
         {
             if (IsConnectionAdvisoryTopic(compositeDestinations[i]))
             {
                 return true;
             }
         }
         return false;
     }
     else
     {
         return destination.Equals(CONNECTION_ADVISORY_TOPIC);
     }
 }
Exemplo n.º 14
0
 public static ActiveMQTopic GetDestinationAdvisoryTopic(ActiveMQDestination destination)
 {
     switch (destination.GetDestinationType())
     {
         case ActiveMQDestination.ACTIVEMQ_QUEUE:
             return QUEUE_ADVISORY_TOPIC;
         case ActiveMQDestination.ACTIVEMQ_TOPIC:
             return TOPIC_ADVISORY_TOPIC;
         case ActiveMQDestination.ACTIVEMQ_TEMPORARY_QUEUE:
             return TEMP_QUEUE_ADVISORY_TOPIC;
         case ActiveMQDestination.ACTIVEMQ_TEMPORARY_TOPIC:
             return TEMP_TOPIC_ADVISORY_TOPIC;
         default:
             throw new NMSException("Unknown destination type: " + destination.DestinationType);
     }
 }
Exemplo n.º 15
0
 public static ActiveMQTopic GetFullAdvisoryTopic(ActiveMQDestination destination)
 {
     String name = FULL_TOPIC_PREFIX + destination.GetDestinationTypeAsString() + "."
             + destination.PhysicalName;
     return new ActiveMQTopic(name);
 }
Exemplo n.º 16
0
 public static ActiveMQTopic GetMessageDLQdAdvisoryTopic(ActiveMQDestination destination)
 {
     String name = MESSAGE_DLQ_TOPIC_PREFIX + destination.GetDestinationTypeAsString() + "."
             + destination.PhysicalName;
     return new ActiveMQTopic(name);
 }
Exemplo n.º 17
0
 public static ActiveMQTopic GetFastProducerAdvisoryTopic(ActiveMQDestination destination)
 {
     String name = FAST_PRODUCER_TOPIC_PREFIX + destination.GetDestinationTypeAsString() + "."
             + destination.PhysicalName;
     return new ActiveMQTopic(name);
 }
Exemplo n.º 18
0
		// 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.");
            }
            else if(destination.PhysicalName == null)
            {
                throw new InvalidDestinationException("The destination object was not given a physical name.");
            }
            else if (destination.IsTemporary)
            {
                String physicalName = destination.PhysicalName;

                if(String.IsNullOrEmpty(physicalName))
                {
                    throw new InvalidDestinationException("Physical name of Destination should be valid: " + destination);
                }
    
                String connectionID = session.Connection.ConnectionId.Value;

                if(physicalName.IndexOf(connectionID) < 0)
                {
                    throw new InvalidDestinationException("Cannot use a Temporary destination from another Connection");
                }
    
                if(!session.Connection.IsTempDestinationActive(destination as ActiveMQTempDestination))
                {
                    throw new InvalidDestinationException("Cannot use a Temporary destination that has been deleted");
                }
            }

			this.session = session;
			this.redeliveryPolicy = this.session.Connection.RedeliveryPolicy;
			this.messageTransformation = this.session.Connection.MessageTransformation;

			if(session.Connection.MessagePrioritySupported)
			{
				this.unconsumedMessages = new SimplePriorityMessageDispatchChannel();
			}
			else
			{
				this.unconsumedMessages = new FifoMessageDispatchChannel();
			}

			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)
			{
				// Get options prefixed with "consumer.*"
				StringDictionary options = URISupport.GetProperties(destination.Options, "consumer.");
				// Extract out custom extension options "consumer.nms.*"
				StringDictionary customConsumerOptions = URISupport.ExtractProperties(options, "nms.");

				URISupport.SetProperties(this.info, options);
				URISupport.SetProperties(this, customConsumerOptions, "nms.");
			}
		}
Exemplo n.º 19
0
        internal void DoSend(ActiveMQDestination destination, ActiveMQMessage message,
                             MessageProducer producer, MemoryUsage producerWindow, TimeSpan sendTimeout)
        {
            ActiveMQMessage msg = message;

            if(destination.IsTemporary && !connection.IsTempDestinationActive(destination as ActiveMQTempDestination))
            {
                throw new InvalidDestinationException("Cannot publish to a deleted Destination: " + destination);
            }

            if(IsTransacted)
            {
                DoStartTransaction();
                msg.TransactionId = TransactionContext.TransactionId;
            }

            msg.RedeliveryCounter = 0;
            msg.BrokerPath = null;

            if(this.connection.CopyMessageOnSend)
            {
                msg = (ActiveMQMessage)msg.Clone();
            }

            msg.OnSend();
            msg.ProducerId = msg.MessageId.ProducerId;

            if(sendTimeout.TotalMilliseconds <= 0 && !msg.ResponseRequired && !connection.AlwaysSyncSend &&
               (!msg.Persistent || connection.AsyncSend || msg.TransactionId != null))
            {
                this.connection.Oneway(msg);

                if(producerWindow != null)
                {
                    // Since we defer lots of the marshaling till we hit the wire, this
                    // might not provide and accurate size. We may change over to doing
                    // more aggressive marshaling, to get more accurate sizes.. this is more
                    // important once users start using producer window flow control.
                    producerWindow.IncreaseUsage(msg.Size());
                }
            }
            else
            {
                if(sendTimeout.TotalMilliseconds > 0)
                {
                    this.connection.SyncRequest(msg, sendTimeout);
                }
                else
                {
                    this.connection.SyncRequest(msg);
                }
            }
        }
Exemplo n.º 20
0
 public abstract bool matches(ActiveMQDestination destination);
Exemplo n.º 21
0
 public static ActiveMQTopic GetExpiredMessageTopic(ActiveMQDestination destination)
 {
     if (destination.IsQueue)
     {
         return GetExpiredQueueMessageAdvisoryTopic(destination);
     }
     return GetExpiredTopicMessageAdvisoryTopic(destination);
 }
Exemplo n.º 22
0
 public static ActiveMQTopic GetNoQueueConsumersAdvisoryTopic(ActiveMQDestination destination)
 {
     String name = NO_QUEUE_CONSUMERS_TOPIC_PREFIX + destination.PhysicalName;
     return new ActiveMQTopic(name);
 }
Exemplo n.º 23
0
 protected void CreateTemporaryDestination(ActiveMQDestination tempDestination)
 {
 }
Exemplo n.º 24
0
		/// <summary>
		/// A helper method to return a descriptive string for the topic or queue
		/// </summary>
		/// <param name="destination"></param>
		/// <returns>a descriptive string for this queue or topic</returns>
		public static String Inspect(ActiveMQDestination destination)
		{
			if(destination is ITopic)
			{
				return "Topic(" + destination.ToString() + ")";
			}
			else
			{
				return "Queue(" + destination.ToString() + ")";
			}
		}