Esempio n. 1
0
        private void ProcessFlow()
        {
            if (!_metadataProvider.TryGetMetadata(Flow.AsPrimaryProcessingFlowId(), out MessageFlowMetadata messageFlowMetadata))
            {
                var msg = "Unsupported flow specified for processing: " + Flow;
                throw new InvalidOperationException(msg);
            }

            var processorSettings = new PerformedOperationsPrimaryFlowProcessorSettings
            {
                MessageBatchSize   = BatchSizeAccordingFailures,
                AppropriatedStages = new[]
                {
                    MessageProcessingStage.Transformation,
                    MessageProcessingStage.Accumulation,
                    MessageProcessingStage.Handling
                },
                FirstFaultTolerantStage = MessageProcessingStage.None
            };

            var messageFlowProcessor = _messageFlowProcessorFactory.CreateSync <IPerformedOperationsFlowProcessorSettings>(messageFlowMetadata, processorSettings);

            try
            {
                messageFlowProcessor.Process();
            }
            finally
            {
                messageFlowProcessor?.Dispose();
            }
        }
        private void ProcessFlow(string flow)
        {
            MessageFlowMetadata messageFlowMetadata;

            if (!_metadataProvider.TryGetMetadata(flow.AsFinalProcessingFlowId(), out messageFlowMetadata))
            {
                string msg = "Unsupported flow specified for processing: " + flow;
                Tracer.Fatal(msg);
                throw new InvalidOperationException(msg);
            }

            ISyncMessageFlowProcessor messageFlowProcessor;

            Tracer.Debug("Launching message flow processing. Target message flow: " + messageFlowMetadata);

            try
            {
                messageFlowProcessor = _messageFlowProcessorFactory.CreateSync <IPerformedOperationsFinalFlowProcessorSettings>(
                    messageFlowMetadata,
                    new PerformedOperationsFinalFlowProcessorSettings
                {
                    MessageBatchSize   = BatchSize,
                    AppropriatedStages = new[]
                    {
                        MessageProcessingStage.Transformation,
                        MessageProcessingStage.Accumulation,
                        MessageProcessingStage.Handling
                    },
                    FirstFaultTolerantStage = _firstFaultTolerantStageSetting.Value,
                    ReprocessingBatchSize   = ReprocessingBatchSize ?? BatchSize
                });
            }
            catch (Exception ex)
            {
                Tracer.Error(ex, "Can't create processor for specified flow " + messageFlowMetadata);
                throw;
            }

            try
            {
                Tracer.Debug("Message flow processor starting. Target message flow: " + messageFlowMetadata);
                messageFlowProcessor.Process();
                Tracer.Debug("Message flow processor finished. Target message flow: " + messageFlowMetadata);
            }
            catch (Exception ex)
            {
                Tracer.Fatal(ex, "Message flow processor unexpectedly interrupted. Target message flow: " + messageFlowMetadata);
                throw;
            }
            finally
            {
                if (messageFlowProcessor != null)
                {
                    messageFlowProcessor.Dispose();
                }
            }
        }
        private void ProcessFlow()
        {
            if (!_metadataProvider.TryGetMetadata(Flow.AsPrimaryProcessingFlowId(), out MessageFlowMetadata messageFlowMetadata))
            {
                var msg = "Unsupported flow specified for processing: " + Flow;
                Tracer.Fatal(msg);
                throw new InvalidOperationException(msg);
            }

            Tracer.Debug("Launching message flow processing. Target message flow: " + messageFlowMetadata);

            ISyncMessageFlowProcessor messageFlowProcessor;

            try
            {
                var processorSettings = new PerformedOperationsPrimaryFlowProcessorSettings
                {
                    MessageBatchSize   = BatchSizeAccordingFailures,
                    AppropriatedStages = new[]
                    {
                        MessageProcessingStage.Transformation,
                        MessageProcessingStage.Accumulation,
                        MessageProcessingStage.Handling
                    },
                    FirstFaultTolerantStage = MessageProcessingStage.None
                };

                messageFlowProcessor = _messageFlowProcessorFactory.CreateSync <IPerformedOperationsFlowProcessorSettings>(messageFlowMetadata, processorSettings);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex, "Can't create processor for specified flow " + messageFlowMetadata);
                throw;
            }

            try
            {
                Tracer.Debug("Message flow processor starting. Target message flow: " + messageFlowMetadata);
                messageFlowProcessor.Process();
                Tracer.Debug("Message flow processor finished. Target message flow: " + messageFlowMetadata);
            }
            catch (Exception ex)
            {
                Tracer.Fatal(ex, "Message flow processor unexpectedly interrupted. Target message flow: " + messageFlowMetadata);
                throw;
            }
            finally
            {
                messageFlowProcessor?.Dispose();
            }
        }