-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Azure Service Bus module DI issues (#5975)
* Switch to Azure Service Bus for message brokering Updated the message broker from in-memory to Azure Service Bus to enhance scalability. Added new configuration settings and dependencies to support Azure Service Bus integration, including scoped service initialization and queue/topic management. * Refactor StartWorkers for dependency injection Updated StartWorkers class to use constructor parameter injection and service scope factory for retrieving services. This refactor eliminates the need for field-level dependency storage, enhancing testability and adherence to the dependency injection principles. Additionally, annotated the class with [UsedImplicitly] to eliminate unused code warnings. * Refactor Worker to use IServiceScopeFactory for dependency resolution Refactored the Worker class to use IServiceScopeFactory for DI instead of directly injecting IWorkflowInbox. This enhances the flexibility and lifecycle management of the dependencies. * Add Azure Service Bus integration toggle Introduced a new configuration constant `useAzureServiceBus` to control the optional integration with Azure Service Bus. Implemented conditional logic to bind Azure Service Bus options from configuration if the flag is enabled. * Add IComposite interface and implement Setup method Introduced a new IComposite interface and added a default Setup method to the Composite class. Updated the ActivityFactory to call the Setup method when an activity is an instance of IComposite. The CompositeExample class demonstrates the use of the new interface and method. * Remove AzureServiceBus configuration setup The AzureServiceBus configuration setup was removed from the Program.cs file. This change aims to streamline configuration and remove unused or unnecessary setup, ensuring the code remains clean and maintainable. * Switch MassTransit broker to in-memory Changed the MassTransit broker from AzureServiceBus to Memory in the application configuration. This adjustment aims to simplify deployment and reduce dependencies in the current environment.
- Loading branch information
1 parent
7c31332
commit a827ab2
Showing
11 changed files
with
100 additions
and
32 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/bundles/Elsa.Server.Web/Activities/CompositeExample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Elsa.AzureServiceBus.Activities; | ||
using Elsa.Extensions; | ||
using Elsa.Workflows.Activities; | ||
using Elsa.Workflows.Attributes; | ||
using Elsa.Workflows.Models; | ||
|
||
namespace Elsa.Server.Web.Activities; | ||
|
||
[Activity("Elsa", "Example")] | ||
public class CompositeExample : Composite | ||
{ | ||
/// <summary> | ||
/// The name of the queue or topic to read from. | ||
/// </summary> | ||
[Input(Description = "The name of the queue or topic to read from.")] | ||
public Input<string> QueueOrTopic { get; set; } = default!; | ||
|
||
private MessageReceived _messageReceived = default!; | ||
|
||
/// <inheritdoc /> | ||
public override void Setup() | ||
{ | ||
_messageReceived = new MessageReceived | ||
{ | ||
QueueOrTopic = QueueOrTopic, | ||
CanStartWorkflow = true | ||
}; | ||
|
||
var writeLine = new WriteLine("Hello World!"); | ||
|
||
Root = new Sequence | ||
{ | ||
Activities = | ||
{ | ||
_messageReceived, | ||
writeLine | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
src/modules/Elsa.AzureServiceBus/HostedServices/CreateQueuesTopicsAndSubscriptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Elsa.Workflows.Contracts; | ||
|
||
public interface IComposite | ||
{ | ||
void Setup(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters