diff --git a/src/Rebus.Operations/Rebus.Operations.Abstractions/IOperationDispatcher.cs b/src/Rebus.Operations/Rebus.Operations.Abstractions/IOperationDispatcher.cs index 5393d54..dc56acc 100644 --- a/src/Rebus.Operations/Rebus.Operations.Abstractions/IOperationDispatcher.cs +++ b/src/Rebus.Operations/Rebus.Operations.Abstractions/IOperationDispatcher.cs @@ -10,7 +10,7 @@ public interface IOperationDispatcher { ValueTask StartNew(object? additionalData = default, IDictionary? additionalHeaders = null) where T : class, new(); ValueTask StartNew(Type commandType, object? additionalData = default, IDictionary? additionalHeaders = null); - ValueTask StartNew(object operationCommand, IDictionary? additionalHeaders = null); - + ValueTask StartNew(object operationCommand, object? additionalData = default, IDictionary? additionalHeaders = null); + } } \ No newline at end of file diff --git a/src/Rebus.Operations/Rebus.Operations.Core/DefaultOperationDispatcher.cs b/src/Rebus.Operations/Rebus.Operations.Core/DefaultOperationDispatcher.cs index f9fd2cb..787d932 100644 --- a/src/Rebus.Operations/Rebus.Operations.Core/DefaultOperationDispatcher.cs +++ b/src/Rebus.Operations/Rebus.Operations.Core/DefaultOperationDispatcher.cs @@ -22,7 +22,7 @@ public DefaultOperationDispatcher( _operationManager = operationManager; } - protected override async ValueTask<(IOperation, object)> CreateOperation(object command, object? additionalData) + protected override async ValueTask<(IOperation, object)> CreateOperation(object command, object? additionalData,IDictionary? additionalHeaders) { return (await _operationManager.GetOrCreateAsync(Guid.NewGuid(), command), command); } diff --git a/src/Rebus.Operations/Rebus.Operations.Core/DefaultOperationTaskDispatcher.cs b/src/Rebus.Operations/Rebus.Operations.Core/DefaultOperationTaskDispatcher.cs index 9dfd62a..ac74f81 100644 --- a/src/Rebus.Operations/Rebus.Operations.Core/DefaultOperationTaskDispatcher.cs +++ b/src/Rebus.Operations/Rebus.Operations.Core/DefaultOperationTaskDispatcher.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using Dbosoft.Rebus.Operations.Workflow; using Microsoft.Extensions.Logging; @@ -22,7 +23,8 @@ public DefaultOperationTaskDispatcher( _operationTaskManager = operationTaskManager; } - protected override async ValueTask<(IOperationTask, object)> CreateTask(Guid operationId, Guid initiatingTaskId, object command, object? additionalData) + protected override async ValueTask<(IOperationTask, object)> CreateTask(Guid operationId, Guid initiatingTaskId, + object command, object? additionalData, IDictionary? additionalHeaders) { var op = await _operationManager.GetByIdAsync(operationId); if (op == null) diff --git a/src/Rebus.Operations/Rebus.Operations.Core/OperationDispatcherBase.cs b/src/Rebus.Operations/Rebus.Operations.Core/OperationDispatcherBase.cs index b930f33..3d090d1 100644 --- a/src/Rebus.Operations/Rebus.Operations.Core/OperationDispatcherBase.cs +++ b/src/Rebus.Operations/Rebus.Operations.Core/OperationDispatcherBase.cs @@ -7,7 +7,6 @@ using System.Text.Json; using System.Threading.Tasks; using Dbosoft.Rebus.Operations.Commands; -using Dbosoft.Rebus.Operations.Workflow; using Microsoft.Extensions.Logging; using Rebus.Bus; @@ -27,9 +26,9 @@ protected OperationDispatcherBase(IBus bus, WorkflowOptions options, ILogger StartNew(object command, IDictionary? additionalHeaders = null) + public ValueTask StartNew(object command, object? additionalData = default, IDictionary? additionalHeaders = null) { - return StartOperation(command, null, additionalHeaders); + return StartOperation(command, additionalData, additionalHeaders); } public ValueTask StartNew(object? additionalData = default, IDictionary? additionalHeaders = null) @@ -44,14 +43,14 @@ protected OperationDispatcherBase(IBus bus, WorkflowOptions options, ILogger CreateOperation(object command, object? additionalData); + protected abstract ValueTask<(IOperation, object)> CreateOperation(object command, object? additionalData, IDictionary? additionalHeaders); protected async ValueTask StartOperation(object command, object? additionalData, IDictionary? additionalHeaders = null) { if (command == null) throw new ArgumentNullException(nameof(command)); - var(operation, taskCommand) = await CreateOperation(command, additionalData); + var(operation, taskCommand) = await CreateOperation(command, additionalData, additionalHeaders); var commandJson = JsonSerializer.Serialize(taskCommand); diff --git a/src/Rebus.Operations/Rebus.Operations.Core/OperationTaskDispatcherBase.cs b/src/Rebus.Operations/Rebus.Operations.Core/OperationTaskDispatcherBase.cs index 3b4f3fe..08b2a0b 100644 --- a/src/Rebus.Operations/Rebus.Operations.Core/OperationTaskDispatcherBase.cs +++ b/src/Rebus.Operations/Rebus.Operations.Core/OperationTaskDispatcherBase.cs @@ -43,7 +43,7 @@ protected OperationTaskDispatcherBase(IBus bus, WorkflowOptions options, ILogger return StartTask(operationId, initiatingTaskId, commandType, additionalData, additionalHeaders); } - protected abstract ValueTask<(IOperationTask, object)> CreateTask(Guid operationId, Guid initiatingTaskId, object command, object? additionalData); + protected abstract ValueTask<(IOperationTask, object)> CreateTask(Guid operationId, Guid initiatingTaskId, object command, object? additionalData, IDictionary? additionalHeaders); protected async ValueTask StartTask(Guid operationId, Guid initiatingTaskId, object command, object? additionalData, IDictionary? additionalHeaders = null) @@ -51,7 +51,7 @@ protected OperationTaskDispatcherBase(IBus bus, WorkflowOptions options, ILogger if (command == null) throw new ArgumentNullException(nameof(command)); - var (task, taskCommand) = await CreateTask(operationId, initiatingTaskId, command, additionalData); + var (task, taskCommand) = await CreateTask(operationId, initiatingTaskId, command, additionalData, additionalHeaders); var commandJson = JsonSerializer.Serialize(taskCommand); var taskMessage = new CreateNewOperationTaskCommand( diff --git a/test/Rebus.Operations.Tests/ExposingHeadersCommandHandler.cs b/test/Rebus.Operations.Tests/ExposingHeadersCommandHandler.cs index 6e6349c..a556b5a 100644 --- a/test/Rebus.Operations.Tests/ExposingHeadersCommandHandler.cs +++ b/test/Rebus.Operations.Tests/ExposingHeadersCommandHandler.cs @@ -13,7 +13,7 @@ public ExposingHeadersCommandHandler(ITaskMessaging messaging) } public static bool Called { get; set; } - public static IDictionary Headers; + public static IDictionary? Headers; public Task Handle(OperationTask message) {