|
| 1 | +using System.Text.Json; |
1 | 2 | using Atc.Azure.Messaging.EventHub; |
| 3 | +using Atc.Azure.Messaging.ServiceBus; |
2 | 4 |
|
3 | 5 | var builder = WebApplication.CreateBuilder(args); |
4 | 6 | builder.Services.AddEndpointsApiExplorer(); |
|
29 | 31 |
|
30 | 32 | internal class SendDataHandler |
31 | 33 | { |
32 | | - private readonly IEventHubPublisher publisher; |
| 34 | + private readonly IEventHubPublisher eventHubPublisher; |
| 35 | + private readonly IServiceBusPublisher serviceBusPublisher; |
33 | 36 |
|
34 | | - public SendDataHandler(IEventHubPublisherFactory factory) |
| 37 | + public SendDataHandler( |
| 38 | + IEventHubPublisherFactory eventHubFactory, |
| 39 | + IServiceBusPublisher serviceBusPublisher) |
35 | 40 | { |
36 | | - publisher = factory.Create("ocpi"); |
| 41 | + eventHubPublisher = eventHubFactory.Create("[existing eventhub]"); |
| 42 | + this.serviceBusPublisher = serviceBusPublisher; |
37 | 43 | } |
38 | 44 |
|
39 | 45 | public async Task<Response> Post(Request request) |
40 | 46 | { |
41 | | - await publisher |
| 47 | + await eventHubPublisher |
42 | 48 | .PublishAsync( |
43 | 49 | request, |
44 | 50 | new Dictionary<string, string>(StringComparer.Ordinal) |
45 | 51 | { |
46 | 52 | { "MessageType", "example" }, |
47 | 53 | }); |
48 | 54 |
|
| 55 | + await serviceBusPublisher |
| 56 | + .PublishAsync( |
| 57 | + "[existing topic|queue", |
| 58 | + "[session id or nothing]", |
| 59 | + JsonSerializer.Serialize(request)); |
| 60 | + |
49 | 61 | return new Response( |
50 | 62 | Guid.NewGuid().ToString("N"), |
51 | 63 | request.A, |
|
0 commit comments