forked from dapr/test-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessagePublisher.cs
32 lines (28 loc) · 909 Bytes
/
MessagePublisher.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
using Dapr.Client;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace PubsubWorkflow
{
public class MessagePublisher
{
private readonly DaprClient Client;
private readonly string PubsubName;
private readonly string Topic;
public MessagePublisher([FromServices] DaprClient client, string pubsubName, string topic)
{
this.Client = client;
this.PubsubName = pubsubName;
this.Topic = topic;
}
internal async void Publish(Object stateInfo)
{
await Client.PublishEventAsync(PubsubName, Topic, "Sample Message");
}
}
}