-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POC add QueueStorage function for local docker env
- Loading branch information
Shaed Parkar
committed
Oct 18, 2024
1 parent
5176b4b
commit ef7d02a
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
BookingQueueSubscriber/BookingQueueSubscriber/BookingQueueStorage.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 System.Threading.Tasks; | ||
using System; | ||
using Microsoft.Azure.WebJobs; | ||
using Microsoft.Azure.WebJobs.Host; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace BookingQueueSubscriber; | ||
|
||
public class BookingQueueStorage | ||
{ | ||
private readonly IMessageHandlerFactory _messageHandlerFactory; | ||
|
||
public BookingQueueStorage(IMessageHandlerFactory messageHandlerFactory) | ||
{ | ||
_messageHandlerFactory = messageHandlerFactory; | ||
} | ||
|
||
[FunctionName("BookingQueueStorage")] | ||
public async Task RunAsync([QueueTrigger("%queueName%", Connection = "AzureWebJobsStorage")] string myQueueItem, ILogger logger) | ||
{ | ||
// get handler | ||
EventMessage eventMessage; | ||
try | ||
{ | ||
eventMessage = MessageSerializer.Deserialise<EventMessage>(myQueueItem); | ||
} | ||
catch (Exception e) | ||
{ | ||
logger.LogCritical(e, "Unable to deserialize into EventMessage \r\n {BookingQueueItem}", myQueueItem); | ||
throw; | ||
} | ||
|
||
var handler = _messageHandlerFactory.Get(eventMessage.IntegrationEvent); | ||
logger.LogInformation("using handler {Handler}", handler.GetType()); | ||
|
||
await handler.HandleAsync(eventMessage.IntegrationEvent); | ||
logger.LogInformation("Process message {EventMessageId} - {EventMessageIntegrationEvent}", eventMessage.Id, | ||
eventMessage.IntegrationEvent); | ||
} | ||
} |
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