Default provider of ISession
Inheritance: ISession, IDispatcher
        private void init(string host, int port)
        {
            ReceivedNumber = 0;
              isFinished = false;
              ReceivedMessages = new List<string>();
              ListionTopics = new List<string>();

              Uri uriSample = new Uri("activemq:tcp://" + host + ":" + port);
              ConnectionFactory confSample = new ConnectionFactory(uriSample);
              connection = (Connection)confSample.CreateConnection();
              connection.Start();
              session = (Session)connection.CreateSession();
        }
Ejemplo 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);
            }
        }
Ejemplo 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();
		}
Ejemplo n.º 4
0
        public SessionExecutor(Session session, IDictionary consumers)
        {
            this.session = session;
            this.consumers = consumers;

            if(this.session.Connection != null && this.session.Connection.MessagePrioritySupported)
            {
               this.messageQueue = new SimplePriorityMessageDispatchChannel();
            }
            else
            {
                this.messageQueue = new FifoMessageDispatchChannel();
            }
        }
Ejemplo n.º 5
0
 internal void RemoveSession(Session session)
 {
     if(!this.closing.Value)
     {
         sessions.Remove(session);
     }
 }
Ejemplo n.º 6
0
 internal void OnSessionException(Session sender, Exception exception)
 {
     if(ExceptionListener != null)
     {
         try
         {
             ExceptionListener(exception);
         }
         catch
         {
             sender.Close();
         }
     }
 }
Ejemplo n.º 7
0
 internal void AddSession(Session session)
 {
     if(!this.closing.Value)
     {
         sessions.Add(session);
     }
 }
Ejemplo n.º 8
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;
			}
Ejemplo n.º 9
0
 public SessionCloseSynchronization(Session session)
 {
     this.session = session;
 }
Ejemplo n.º 10
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.");
			}
		}
Ejemplo n.º 11
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.");
            }
        }
Ejemplo n.º 12
0
        public TransactionContext(Session session)
		{
            this.session = session;
            this.connection = session.Connection;
        }
Ejemplo n.º 13
0
 public StompConnection(string host, int port)
 {
     Uri uriSample = new Uri("activemq:tcp://" + host + ":" + port);
     ConnectionFactory confSample = new ConnectionFactory(uriSample);
     Connection connection = (Connection)confSample.CreateConnection();
     connection.Start();
     //writeLog("Stomp Start:");
     //create session
     session = (Session)connection.CreateSession();
 }