Exemplo n.º 1
0
        private void Query()
        {
            try
            {
                var max = _currentOffset - _lastEventMessageId;
                if (max > 0)
                {
                    var start = (MessageId)MessageIdUtils.GetMessageId(_lastEventMessageId);
                    var end   = (MessageId)MessageIdUtils.GetMessageId(_currentOffset);
                    var query =
                        $"select {string.Join(", ", _message.Columns)}, __message_id__, __publish_time__, __properties__, __key__, __producer_name__, __sequence_id__, __partition__ from \"{_message.Topic}\" where __partition__ = {_partitionIndex} AND CAST(split_part(replace(replace(__message_id__, '('), ')'), ',', 1) AS BIGINT) BETWEEN bigint '{start.LedgerId}' AND bigint '{end.LedgerId}' AND CAST(split_part(replace(replace(__message_id__, '('), ')'), ',', 2) AS BIGINT) BETWEEN bigint '{start.EntryId + 1}' AND bigint '{end.EntryId}' ORDER BY __publish_time__ ASC LIMIT {_queryRange}";
                    var options = _message.Options;
                    options.Catalog = "pulsar";
                    options.Schema  = "" + _message.Tenant + "/" + _message.Namespace + "";
                    options.Execute = query;
                    var session = options.ToClientSession();

                    var executor = new Executor(session, options, _self, _log);
                    _log.Info($"Executing: {options.Execute}");
                    _ = executor.Run().GetAwaiter().GetResult();
                    _lastEventMessageId = _currentOffset;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
            finally
            {
                _queryCancelable = _scheduler.ScheduleOnceCancelable(TimeSpan.FromSeconds(10), Query);
            }
        }
Exemplo n.º 2
0
 private void LiveConsume()
 {
     Receive <ReceivedMessage <T> >(c =>
     {
         _parent.Tell(c);
         _currentOffset = MessageIdUtils.GetOffset(c.Message.MessageId);
     });
     _flowSenderCancelable = _scheduler.ScheduleOnceCancelable(TimeSpan.FromSeconds(60), SendFlow);
 }
Exemplo n.º 3
0
 private void LiveConsume()
 {
     Receive <ReceivedMessage <T> >(c =>
     {
         var props  = c.Message.Properties;
         var tagged = props.FirstOrDefault(x => x.Key.Equals(_tag.Key, StringComparison.OrdinalIgnoreCase) && x.Value.Equals(_tag.Value, StringComparison.OrdinalIgnoreCase));
         if (!string.IsNullOrWhiteSpace(tagged.Value))
         {
             Context.Parent.Tell(c);
         }
         _currentOffset = MessageIdUtils.GetOffset(c.Message.MessageId);
         //_sequenceId++;
     });
     _flowSenderCancelable = _scheduler.ScheduleOnceCancelable(TimeSpan.FromSeconds(60), SendFlow);
 }