Пример #1
0
        public RunScheduledJobs(IWorkerQueue workers, IDocumentStore store, EnvelopeTables marker, CompositeTransportLogger logger, MartenRetries retries)
        {
            _workers = workers;
            _store   = store;
            _marker  = marker;
            _logger  = logger;
            _retries = retries;

            _findReadyToExecuteJobs = $"select body from {marker.Incoming} where status = '{TransportConstants.Scheduled}' and execution_time <= :time";
            _markOwnedIncomingSql   = $"update {marker.Incoming} set owner_id = :owner, status = '{TransportConstants.Incoming}' where id = ANY(:idlist)";
        }
Пример #2
0
        public RecoverIncomingMessages(IWorkerQueue workers, BusSettings settings, EnvelopeTables marker,
                                       ISchedulingAgent schedulingAgent, CompositeTransportLogger logger)
        {
            _workers         = workers;
            _settings        = settings;
            _marker          = marker;
            _schedulingAgent = schedulingAgent;
            _logger          = logger;

            _findAtLargeEnvelopesSql = $"select body from {marker.Incoming} where owner_id = {TransportConstants.AnyNode} and status = '{TransportConstants.Incoming}' limit {settings.Retries.RecoveryBatchSize}";
        }
Пример #3
0
        public RecoverOutgoingMessages(IChannelGraph channels, BusSettings settings, EnvelopeTables marker, ISchedulingAgent schedulingAgent, CompositeTransportLogger logger)
        {
            _channels        = channels;
            _settings        = settings;
            _marker          = marker;
            _schedulingAgent = schedulingAgent;
            _logger          = logger;

            _findUniqueDestinations   = $"select distinct destination from {_marker.Outgoing}";
            _findOutgoingEnvelopesSql = $"select body from {marker.Outgoing} where owner_id = {TransportConstants.AnyNode} and destination = :destination limit {settings.Retries.RecoveryBatchSize}";
            _deleteOutgoingSql        = $"delete from {marker.Outgoing} where owner_id = :owner and destination = :destination";
        }
Пример #4
0
        public ReassignFromDormantNodes(EnvelopeTables marker, BusSettings settings)
        {
            _marker = marker;

            _reassignDormantNodeSql = $@"
update {marker.Incoming}
  set owner_id = 0
where
  owner_id in (
    select distinct owner_id from {marker.Incoming}
    where owner_id != 0 AND owner_id != {settings.UniqueNodeId} AND pg_try_advisory_xact_lock(owner_id)
  );

update {marker.Outgoing}
  set owner_id = 0
where
  owner_id in (
    select distinct owner_id from {marker.Outgoing}
    where owner_id != 0 AND owner_id != {settings.UniqueNodeId} AND pg_try_advisory_xact_lock(owner_id)
  );
";
        }
Пример #5
0
        public SchedulingAgent(IChannelGraph channels, IWorkerQueue workers, IDocumentStore store, BusSettings settings, CompositeTransportLogger logger, StoreOptions storeOptions, MartenRetries retries)
        {
            _channels     = channels;
            _workers      = workers;
            _store        = store;
            _settings     = settings;
            _logger       = logger;
            _storeOptions = storeOptions;

            _worker = new ActionBlock <IMessagingAction>(processAction, new ExecutionDataflowBlockOptions
            {
                MaxDegreeOfParallelism = 1
            });

            var marker = new EnvelopeTables(_settings, _storeOptions);

            _scheduledJobs    = new RunScheduledJobs(_workers, _store, marker, logger, retries);
            _incomingMessages = new RecoverIncomingMessages(_workers, _settings, marker, this, _logger);
            _outgoingMessages = new RecoverOutgoingMessages(_channels, _settings, marker, this, _logger);

            _nodeReassignment = new ReassignFromDormantNodes(marker, settings);
        }