public void HandleStart(ExternalTask <TJob> task)
        {
            var result = new ExternalTaskResult
            {
                ExternalTaskId = task.ExternalTaskId,
                Topic          = task.Topic,
                Status         = ExternalTaskResultStatus.RUNNING,
                Variables      = task.Variables
            };

            SendToResultChannel(result);
        }
        public void HandleSuccess(ExternalTask <TJob> task)
        {
            var result = new ExternalTaskResult
            {
                ExternalTaskId = task.ExternalTaskId,
                Topic          = task.Topic,
                Status         = ExternalTaskResultStatus.FINISHED,
                Variables      = task.Variables
            };

            SendToResultChannel(result);
        }
        public void HandleError(ExternalTask <TJob> task, string errorMessage)
        {
            var result = new ExternalTaskErrorResult
            {
                ExternalTaskId = task.ExternalTaskId,
                Topic          = task.Topic,
                Status         = ExternalTaskResultStatus.ERROR,
                Variables      = task.Variables,
                ErrorMessage   = errorMessage
            };

            SendToResultChannel(result);
        }
        public Task StartAsync(CancellationToken cancellationToken)
        {
            topicChannel.QueueDeclare(queue: configuration.TopicChannel, durable: false, exclusive: false, autoDelete: false, arguments: null);
            resultChannel.QueueDeclare(queue: configuration.ResultChannel, durable: false, exclusive: false, autoDelete: false, arguments: null);

            var consumer = new EventingBasicConsumer(topicChannel);

            consumer.Received += (model, ea) =>
            {
                var body    = ea.Body.ToArray();
                var message = Encoding.UTF8.GetString(body);
                ExternalTask <TJob> task = JsonSerializer.Deserialize <ExternalTask <TJob> >(message);
                logger.LogInformation("recieved task", task);
                HandleTask(task);
            };

            topicChannel.BasicConsume(queue: configuration.TopicChannel, autoAck: true, consumer: consumer);

            return(Task.CompletedTask);
        }
 public virtual void HandleTask(ExternalTask <TJob> task)
 {
 }