Skip to content

Commit

Permalink
POC add QueueStorage function for local docker env
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaed Parkar committed Oct 18, 2024
1 parent 5176b4b commit ef7d02a
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@
"System.Memory.Data": "1.0.2"
}
},
"Azure.Storage.Common": {
"type": "Transitive",
"resolved": "12.11.0",
"contentHash": "BPZ1JwYvehHGoTSXhXfAmwtFYejJghE6dkKvpZtPIL0DulzSIJdll9OZI+h5W+3wLYK0yn5hc1r6mvId0q4npA==",
"dependencies": {
"Azure.Core": "1.24.0",
"System.IO.Hashing": "6.0.0"
}
},
"Azure.Storage.Queues": {
"type": "Transitive",
"resolved": "12.10.0",
"contentHash": "RD+rDy2O763jJXpvaOd03I3NSIrGpjq5YPzVkPydXnhMIzvjrv3X6ogDl+QgZs1ssuRcqjCh0RBvaaW6tt2EYw==",
"dependencies": {
"Azure.Storage.Common": "12.11.0",
"System.Memory.Data": "1.0.2",
"System.Text.Json": "4.7.2"
}
},
"BookingsApi.Client": {
"type": "Transitive",
"resolved": "2.3.10",
Expand Down Expand Up @@ -615,6 +634,16 @@
"Microsoft.Extensions.Azure": "1.2.0"
}
},
"Microsoft.Azure.WebJobs.Extensions.Storage.Queues": {
"type": "Transitive",
"resolved": "5.0.1",
"contentHash": "NCNMBtMOdKreEriYYLhnL1BpYwn8x1bhYAMbB7qadEvyobFyQ4j0z877TDq6S03l0aZRi3WL9XhkeiubRxneZA==",
"dependencies": {
"Azure.Storage.Queues": "12.10.0",
"Microsoft.Azure.WebJobs": "3.0.32",
"Microsoft.Extensions.Azure": "1.1.1"
}
},
"Microsoft.Azure.WebJobs.Host.Storage": {
"type": "Transitive",
"resolved": "3.0.14",
Expand Down Expand Up @@ -1550,6 +1579,11 @@
"System.Runtime": "4.3.0"
}
},
"System.IO.Hashing": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "Rfm2jYCaUeGysFEZjDe7j1R4x6Z6BzumS/vUT5a1AA/AWJuGX71PoGB0RmpyX3VmrGqVnAwtfMn39OHR8Y/5+g=="
},
"System.Linq": {
"type": "Transitive",
"resolved": "4.3.0",
Expand Down Expand Up @@ -2287,6 +2321,7 @@
"Microsoft.AspNetCore.Hosting": "[2.2.7, )",
"Microsoft.Azure.WebJobs": "[3.0.33, )",
"Microsoft.Azure.WebJobs.Extensions.ServiceBus": "[5.8.0, )",
"Microsoft.Azure.WebJobs.Extensions.Storage.Queues": "[5.0.1, )",
"Microsoft.Extensions.Configuration.Abstractions": "[6.0.0, )",
"Microsoft.Extensions.Configuration.KeyPerFile": "[6.0.1, )",
"Microsoft.Extensions.Configuration.UserSecrets": "[6.0.1, )",
Expand Down
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.33" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.8.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage.Queues" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.KeyPerFile" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
Expand Down
35 changes: 35 additions & 0 deletions BookingQueueSubscriber/BookingQueueSubscriber/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@
"Microsoft.Extensions.Azure": "1.2.0"
}
},
"Microsoft.Azure.WebJobs.Extensions.Storage.Queues": {
"type": "Direct",
"requested": "[5.0.1, )",
"resolved": "5.0.1",
"contentHash": "NCNMBtMOdKreEriYYLhnL1BpYwn8x1bhYAMbB7qadEvyobFyQ4j0z877TDq6S03l0aZRi3WL9XhkeiubRxneZA==",
"dependencies": {
"Azure.Storage.Queues": "12.10.0",
"Microsoft.Azure.WebJobs": "3.0.32",
"Microsoft.Extensions.Azure": "1.1.1"
}
},
"Microsoft.Extensions.Configuration.Abstractions": {
"type": "Direct",
"requested": "[6.0.0, )",
Expand Down Expand Up @@ -282,6 +293,25 @@
"System.Memory.Data": "1.0.2"
}
},
"Azure.Storage.Common": {
"type": "Transitive",
"resolved": "12.11.0",
"contentHash": "BPZ1JwYvehHGoTSXhXfAmwtFYejJghE6dkKvpZtPIL0DulzSIJdll9OZI+h5W+3wLYK0yn5hc1r6mvId0q4npA==",
"dependencies": {
"Azure.Core": "1.24.0",
"System.IO.Hashing": "6.0.0"
}
},
"Azure.Storage.Queues": {
"type": "Transitive",
"resolved": "12.10.0",
"contentHash": "RD+rDy2O763jJXpvaOd03I3NSIrGpjq5YPzVkPydXnhMIzvjrv3X6ogDl+QgZs1ssuRcqjCh0RBvaaW6tt2EYw==",
"dependencies": {
"Azure.Storage.Common": "12.11.0",
"System.Memory.Data": "1.0.2",
"System.Text.Json": "4.7.2"
}
},
"BookingsApi.Common.DotNet6": {
"type": "Transitive",
"resolved": "2.3.10",
Expand Down Expand Up @@ -1578,6 +1608,11 @@
"System.Runtime": "4.3.0"
}
},
"System.IO.Hashing": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "Rfm2jYCaUeGysFEZjDe7j1R4x6Z6BzumS/vUT5a1AA/AWJuGX71PoGB0RmpyX3VmrGqVnAwtfMn39OHR8Y/5+g=="
},
"System.Linq": {
"type": "Transitive",
"resolved": "4.3.0",
Expand Down

0 comments on commit ef7d02a

Please sign in to comment.