Update Azure Service Bus sample
This commit is contained in:
parent
6670264194
commit
d6ea3f440c
|
|
@ -1,5 +1,6 @@
|
|||
using Elsa.Activities.AzureServiceBus.Extensions;
|
||||
using Elsa.Samples.AzureServiceBusWorker.Workflows;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using NodaTime;
|
||||
|
|
@ -22,7 +23,7 @@ namespace Elsa.Samples.AzureServiceBusWorker
|
|||
.AddElsa()
|
||||
.AddConsoleActivities()
|
||||
.AddTimerActivities(options => options.SweepInterval = Duration.FromSeconds(1))
|
||||
.AddAzureServiceBusActivities(options => options.ConnectionString = "Endpoint=sb://elsa-workflows-2.servicebus.windows.net/;SharedAccessKeyName=Elsa;SharedAccessKey=hAIa+fFuUbHi94y1Z0uO/2UTccjN/y4W0xvpaUd/cr4=")
|
||||
.AddAzureServiceBusActivities(options => options.ConnectionString = hostContext.Configuration.GetConnectionString("AzureServiceBus"))
|
||||
.AddWorkflow<ProducerWorkflow>()
|
||||
.AddWorkflow<ConsumerWorkflow>();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Elsa.Activities.AzureServiceBus.Activities;
|
||||
using Elsa.Activities.AzureServiceBus;
|
||||
using Elsa.Activities.Console;
|
||||
using Elsa.Builders;
|
||||
using Elsa.Samples.AzureServiceBusWorker.Messages;
|
||||
|
|
@ -10,7 +10,7 @@ namespace Elsa.Samples.AzureServiceBusWorker.Workflows
|
|||
public void Build(IWorkflowBuilder workflow)
|
||||
{
|
||||
workflow
|
||||
.StartWith<AzureServiceBusMessageReceived>(messageReceived => messageReceived.Set(x => x.QueueName, "greetings"))
|
||||
.MessageReceived<Greeting>("greetings")
|
||||
.WriteLine(context =>
|
||||
{
|
||||
var greeting = context.GetInput<Greeting>();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
using Elsa.Activities.AzureServiceBus.Activities;
|
||||
using Elsa.Activities.AzureServiceBus;
|
||||
using Elsa.Activities.Console;
|
||||
using Elsa.Activities.Timers;
|
||||
using Elsa.Builders;
|
||||
|
|
@ -10,23 +10,19 @@ namespace Elsa.Samples.AzureServiceBusWorker.Workflows
|
|||
{
|
||||
public class ProducerWorkflow : IWorkflow
|
||||
{
|
||||
private readonly IClock _clock;
|
||||
private readonly Random _random;
|
||||
|
||||
public ProducerWorkflow(IClock clock)
|
||||
public ProducerWorkflow()
|
||||
{
|
||||
_clock = clock;
|
||||
_random = new Random();
|
||||
}
|
||||
|
||||
public void Build(IWorkflowBuilder workflow)
|
||||
{
|
||||
workflow
|
||||
.InstantEvent(_clock.GetCurrentInstant().Plus(Duration.FromSeconds(5)))
|
||||
.TimerEvent(Duration.FromSeconds(5))
|
||||
.WriteLine("Sending a random greeting to the \"greetings\" queue.")
|
||||
.Then<SendAzureServiceBusMessage>(sendMessage => sendMessage
|
||||
.Set(x => x.Message, GetRandomGreeting)
|
||||
.Set(x => x.QueueName, "greetings"));
|
||||
.SendMessage("greetings", GetRandomGreeting);
|
||||
}
|
||||
|
||||
private Greeting GetRandomGreeting()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"AzureServiceBus": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue