public async Task <IEntity> GetDomainEntity(IWorkflowMessageTransportFactoryProvider workflowMessageTransportFactoryProvider,
                                                    WorkflowConfiguration workflowConfiguration, IWorkflowInstance workflowInstance, CancellationToken cancellationToken = default)
        {
            var endpointCode                = $"EntityType::{workflowInstance.EntityType}";
            var endpointConfiguration       = workflowConfiguration.FindEndpointConfiguration(endpointCode);
            var eventRequestWorkflowMessage = new EntityRequestWorkflowMessage(workflowInstance.EntityType, workflowInstance.EntityId);

            Log.Verbose("Sending entity request message [{endpointCode}::{entityId}] to {endpoint} [{workflowInstanceId}]",
                        endpointCode, workflowInstance.EntityId, endpointConfiguration.Address, workflowInstance.Id);

            var messageTransport        = workflowMessageTransportFactoryProvider.CreateMessageTransportFactory(endpointConfiguration.Type).CreateMessageTransport(endpointConfiguration.Address);
            var responseWorkflowMessage = await messageTransport.Request <IEntityRequestWorkflowMessage, IEntityResponseWorkflowMessage>(
                endpointConfiguration, eventRequestWorkflowMessage, cancellationToken).ConfigureAwait(false);

            Log.Verbose("Received entity response message [{endpointCode}::{entityId}::{status}] from {endpoint} [{workflowInstanceId}]",
                        endpointCode, workflowInstance.EntityId, responseWorkflowMessage.ExecutionStatus, endpointConfiguration.Address, workflowInstance.Id);

            if (responseWorkflowMessage.ExecutionStatus == EntityRequestExecutionStatus.Completed)
            {
                return(new JsonEntity(responseWorkflowMessage.EntityJsonPayload));
            }

            if (responseWorkflowMessage.ExecutionStatus == EntityRequestExecutionStatus.NotFound)
            {
                Log.Error("Can not find {entityType} {entityId}... stopping {workflowInstanceId} processing",
                          workflowInstance.EntityType, workflowInstance.EntityId, workflowInstance.Id);

                throw new WorkflowException($"No entity has been found {workflowInstance.EntityType}::{workflowInstance.EntityId}");
            }

            throw new WorkflowException($"An error has occurred during obtaining {workflowInstance.EntityType}::{workflowInstance.EntityId}");
        }
Beispiel #2
0
 public WorkflowEngineFactory(
     IActivityFactory activityFactory,
     IEventHandlerFactory eventHandlerFactory,
     IWorkflowDomainStore workflowDomainStore,
     IWorkflowStoreFactory workflowStoreFactory,
     IWorkflowMessageTransportFactoryProvider workflowMessageTransportFactoryProvider,
     IWorkflowRuntimeConfigurationFactory workflowRuntimeConfigurationFactory)
 {
     _activityFactory      = activityFactory;
     _eventHandlerFactory  = eventHandlerFactory;
     _workflowDomainStore  = workflowDomainStore;
     _workflowStoreFactory = workflowStoreFactory;
     _workflowRuntimeConfigurationFactory     = workflowRuntimeConfigurationFactory;
     _workflowMessageTransportFactoryProvider = workflowMessageTransportFactoryProvider;
 }
 public WorkflowEngineBuilder WithMessageTransportFactoryProvider(IWorkflowMessageTransportFactoryProvider workflowMessageTransportFactoryProvider)
 {
     WorkflowMessageTransportFactoryProvider = workflowMessageTransportFactoryProvider;
     return(this);
 }
 public Task <IEntity> GetDomainEntity(IWorkflowMessageTransportFactoryProvider workflowMessageTransportFactoryProvider,
                                       WorkflowConfiguration workflowConfiguration, IWorkflowInstance workflowInstance, CancellationToken cancellationToken = default)
 {
     return(Task.FromResult <IEntity>(null));
 }