Exemplo n.º 1
0
        public void Start()
        {
            _subscription = new Subscription(_model, _queueName, false);
            var consumer = new ConsumeDelegate(Poll);

            consumer.Invoke();
        }
Exemplo n.º 2
0
        //internal delegate to run the queue consumer on a seperate thread

        public void StartReceiving()
        {
            IsReceiving = true;
            var c = new ConsumeDelegate(Consume);

            c.BeginInvoke(null, null);
        }
Exemplo n.º 3
0
        public void StartListening()
        {
            isListening = true;
            ConsumeDelegate c = new ConsumeDelegate(Consume);

            c.BeginInvoke(null, null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Keeps consuming (calling) the function for token consumption until
        /// it fails. It will only return true though if at least one of the
        /// function calls succeed. Upon failure, it will only rewind back to
        /// the point of failure. This is greedy.
        /// </summary>
        /// <param name="consumerFunc">The function to call.</param>
        /// <returns>True if at least one was consumed, false if none was
        /// consumed.</returns>
        private bool ConsumeOneOrMore(ConsumeDelegate consumerFunc)
        {
            Assert(consumerFunc != null);

            int marker = tokenIterator.GetMarker();

            // Needs to consume at least one.
            if (!consumerFunc())
            {
                tokenIterator.SetToMarker(marker);
                return(false);
            }

            // Now do a greedy consumption.
            bool consumed = true;

            while (consumed)
            {
                marker   = tokenIterator.GetMarker();
                consumed = consumerFunc();

                if (!consumed)
                {
                    tokenIterator.SetToMarker(marker);
                }
            }

            return(true);
        }
Exemplo n.º 5
0
        public void StartConsuming()
        {
            isConsuming = true;
            ConsumeDelegate c = Consume;

            c.BeginInvoke(null, null);
        }
Exemplo n.º 6
0
        public void StartConsuming()
        {
            isConsuming = true;
            var c = new ConsumeDelegate(Consume);

            c.BeginInvoke(null, null);
        }
Exemplo n.º 7
0
        public void Start()
        {
            _subscription = new Subscription(_channel, QueueName, true);

            var consumer = new ConsumeDelegate(Poll);

            consumer.Invoke();
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        public void StartConsuming()
        {
            Model.BasicQos(0, 1, false);
            QueueName = Model.QueueDeclare();
            Model.QueueBind(QueueName, ExchangeName, "");
            isConsuming = true;
            ConsumeDelegate c = new ConsumeDelegate(Consume);

            c.BeginInvoke(null, null);
        }
Exemplo n.º 9
0
        public void StartConsuming(string queueName)
        {
            Debug.Print(queueName + "-------queueneame");
            //Debug.Print("-----"+Model);
            Model.BasicQos(0, 1, false);
            Model.QueueDeclare(queueName, true, false, false, null);
            Model.QueueBind(queueName, exchange, queueName);
            isConsuming = true;
            ConsumeDelegate c = new ConsumeDelegate(Consume);

            c.BeginInvoke(queueName, null, null);
        }
Exemplo n.º 10
0
 public void StartConsuming()
 {
     try
     {
         isConsuming = true;
         ConsumeDelegate c = new ConsumeDelegate(Consume);
         c.BeginInvoke(null, null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 11
0
        public void StartConsuming()
        {
            Model.BasicQos(0, 1, false);
            QueueName = Model.QueueDeclare();
            Model.QueueBind(QueueName, ExchangeName, "");
            isConsuming = true;
            ConsumeDelegate c = new ConsumeDelegate(Consume);

            c.BeginInvoke(null, null);

            //if (ExchangeTypeName == ExchangeType.Fanout)
            //AddBinding("");//fanout has default binding
        }
        public void StartConsuming()
        {

                Model.BasicQos(0, 1, false);
                QueueName = Model.QueueDeclare();
                Model.QueueBind(QueueName, ExchangeName, "");
                isConsuming = true;
                ConsumeDelegate c = new ConsumeDelegate(Consume);
                c.BeginInvoke(null, null);
                
                //if (ExchangeTypeName == ExchangeType.Fanout)
                    //AddBinding("");//fanout has default binding

        }
Exemplo n.º 13
0
        public SaveAsynchronous(ConsumeDelegate consumeMethod, string threadName, ThreadPriority threadPriority, bool autoStart)
        {
            if (consumeMethod == null) throw new ArgumentNullException("consumeMethod");

            _consumeMethod = consumeMethod;
            _queue = Queue.Synchronized(new Queue());
            _syncEvents = new SyncEvents();
            _threadPriority = threadPriority;
            _threadName = threadName;

            ExecutionTime();

            if (autoStart) Start();
        }
Exemplo n.º 14
0
        /// <summary>
        /// Start a consumer thread on a topic that send messages to handler
        /// </summary>
        /// <param name="busConnector">Connection to a Kafka bus</param>
        /// <param name="topicName">Name of topict to fetch</param>
        /// <param name="partitionId">Partition to fetch</param>
        /// <param name="startOffset">Office to start fetch from. 0 = From first message. -1 = Next message >0 = At offset </param>
        /// <param name="consumeDelegate"></param>
        public void Start(KafkaBusConnector busConnector, string topicName, int partitionId, long startOffset, ConsumeDelegate consumeDelegate)
        {
            KafkaMessageStream messageStream;
            if (startOffset == 0)
                messageStream = busConnector.CreateMessageStream(topicName, partitionId, KafkaMessageStream.StreamStart.Beginning);
            else if (startOffset < 0)
                messageStream = busConnector.CreateMessageStream(topicName, partitionId,
                                                                 KafkaMessageStream.StreamStart.Next);
            else
                messageStream = busConnector.CreateMessageStream(topicName, partitionId, startOffset);

            worker = new Worker(messageStream, consumeDelegate);
            var workerThread = new Thread(worker.ConsumeMessages);
            workerThread.Start();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Keeps consuming (calling) the function for token consumption until
        /// it fails. Will advance the stream always until the last point of
        /// failure. Similar to the Kleene Star.
        /// </summary>
        /// <param name="consumerFunc">The function to call.</param>
        /// <returns>True always (this cannot fail).</returns>
        private bool ConsumeZeroOrMore(ConsumeDelegate consumerFunc)
        {
            Assert(consumerFunc != null);

            bool consumed = true;

            while (consumed)
            {
                int marker = tokenIterator.GetMarker();
                consumed = consumerFunc();

                if (!consumed)
                {
                    tokenIterator.SetToMarker(marker);
                }
            }

            return(true);
        }
Exemplo n.º 16
0
        public void Start()
        {
            /*
             * var consumer = new QueueingBasicConsumer(_model);
             * _model.BasicConsume(QueueName, false, consumer);
             *
             * while (Enabled)
             * {
             *  var deliveryArgs = (BasicDeliverEventArgs)consumer.Queue.Dequeue();
             *
             *  var message = Encoding.Default.GetString(deliveryArgs.Body);
             *
             *  Console.WriteLine("Message Received - {0}", message);
             *  _model.BasicAck(deliveryArgs.DeliveryTag, false);
             * }
             */

            _subscription = new Subscription(_model, QueueName, false);
            var consumer = new ConsumeDelegate(Poll);

            consumer.Invoke();
        }
        /// <summary>
        /// Starts receiving a message from a queue
        /// </summary>
        public void Start()
        {
            var consumer = new ConsumeDelegate(Poll);

            consumer.Invoke();
        }
Exemplo n.º 18
0
 public void StartConsuming()
 {
     isConsuming = true;
     var c = new ConsumeDelegate(Consume);
     c.BeginInvoke(null, null);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Start a consumer thread on a topic that send messages to handler
        /// </summary>
        /// <param name="busConnector">Connection to a Kafka bus</param>
        /// <param name="topicName">Name of topict to fetch</param>
        /// <param name="partitionId">Partition to fetch</param>
        /// <param name="startOffset">Office to start fetch from. 0 = From first message. -1 = Next message >0 = At offset </param>
        /// <param name="consumeDelegate"></param>
        public void Start(KafkaBusConnector busConnector, string topicName, int partitionId, long startOffset, ConsumeDelegate consumeDelegate)
        {
            KafkaMessageStream messageStream;

            if (startOffset == 0)
            {
                messageStream = busConnector.CreateMessageStream(topicName, partitionId, KafkaMessageStream.StreamStart.Beginning);
            }
            else if (startOffset < 0)
            {
                messageStream = busConnector.CreateMessageStream(topicName, partitionId,
                                                                 KafkaMessageStream.StreamStart.Next);
            }
            else
            {
                messageStream = busConnector.CreateMessageStream(topicName, partitionId, startOffset);
            }

            worker = new Worker(messageStream, consumeDelegate);
            var workerThread = new Thread(worker.ConsumeMessages);

            workerThread.Start();
        }
Exemplo n.º 20
0
 internal Worker(KafkaMessageStream messageStream, ConsumeDelegate handler)
 {
     this.messageStream = messageStream;
     this.handler       = handler;
 }
Exemplo n.º 21
0
 internal Worker(KafkaMessageStream messageStream, ConsumeDelegate handler)
 {
     this.messageStream = messageStream;
     this.handler = handler;
 }
Exemplo n.º 22
0
        /// <summary>
        /// 开始取消息
        /// </summary>
        public void Start()
        {
            var consumer = new ConsumeDelegate(EstablishConnection.Poll);

            consumer(Enabled);
        }