Esempio n. 1
0
        public void Start()
        {
            try
            {
                reconnectMutex.WaitOne();
                if (started)
                {
                    Tracer.Debug("FailoverTransport Already Started.");
                    return;
                }

                Tracer.Debug("FailoverTransport Started.");
                started = true;
                stateTracker.MaxCacheSize  = MaxCacheSize;
                stateTracker.TrackMessages = TrackMessages;
                if (ConnectedTransport != null)
                {
                    stateTracker.DoRestore(ConnectedTransport);
                }
                else
                {
                    Reconnect();
                }
            }
            finally
            {
                reconnectMutex.ReleaseMutex();
            }
        }
Esempio n. 2
0
        public void Start()
        {
            lock (reconnectMutex)
            {
                if (started)
                {
                    Tracer.Debug("FailoverTransport Already Started.");
                    return;
                }

                Tracer.Debug("FailoverTransport Started.");
                started = true;
                stateTracker.MaxCacheSize  = MaxCacheSize;
                stateTracker.TrackMessages = TrackMessages;
                if (ConnectedTransport != null)
                {
                    Tracer.Debug("FailoverTransport already connected, start is restoring.");
                    stateTracker.DoRestore(ConnectedTransport);
                }
                else
                {
                    Tracer.Debug("FailoverTransport not connected, start is reconnecting.");
                    Reconnect(false);
                }
            }
        }
        public void TestMessageCache()
        {
            TrackingTransport      transport = new TrackingTransport();
            ConnectionStateTracker tracker   = new ConnectionStateTracker();

            tracker.TrackMessages = true;

            ConnectionData conn = CreateConnectionState(tracker);

            tracker.MaxCacheSize = 4;

            int sequenceId = 1;

            for (int i = 0; i < 10; ++i)
            {
                MessageId id = new MessageId();
                id.ProducerId         = conn.producer.ProducerId;
                id.ProducerSequenceId = sequenceId++;
                Message message = new Message();
                message.MessageId = id;

                tracker.ProcessMessage(message);
                tracker.TrackBack(message);
            }

            tracker.DoRestore(transport);

            Assert.AreEqual(4, transport.messages.Count);
        }
Esempio n. 4
0
        public void Start()
        {
            lock (reconnectMutex)
            {
                if (started)
                {
                    Tracer.Debug("FailoverTransport Already Started.");
                    return;
                }

                Tracer.Debug("FailoverTransport Started.");
                started = true;
                if (ConnectedTransport != null)
                {
                    stateTracker.DoRestore(ConnectedTransport);
                }
                else
                {
                    Reconnect();
                }
            }
        }
        public void TestMessagePullCache2()
        {
            TrackingTransport      transport = new TrackingTransport();
            ConnectionStateTracker tracker   = new ConnectionStateTracker();

            tracker.TrackMessages = true;

            tracker.MaxCacheSize = 10;
            ConnectionData conn = CreateConnectionState(tracker);

            for (int i = 0; i < 100; ++i)
            {
                MessagePull         pull        = new MessagePull();
                ActiveMQDestination destination = new ActiveMQTopic("TEST");
                pull.ConsumerId  = conn.consumer.ConsumerId;
                pull.Destination = destination;
                tracker.ProcessMessagePull(pull);
                tracker.TrackBack(pull);
            }

            tracker.DoRestore(transport);

            Assert.AreEqual(1, transport.messagePulls.Count);
        }