Last active
September 22, 2019 05:42
-
-
Save ankitvijay/684e078d745dfbdab56a3d5df7104090 to your computer and use it in GitHub Desktop.
TimerTriggerAzureFunction- Modified
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
using System; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Extensions.Logging; | |
using Newtonsoft.Json; | |
namespace DemoNServiceBusSubscriberAndAzureFunctionPublisher | |
{ | |
public static class TimerTriggerAzureFunction | |
{ | |
[FunctionName("QueueMessageToWorker")] | |
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, | |
[ServiceBus("%AzureServiceBusQueue%", Connection = "AzureServiceBusConnectionString")] | |
ICollector<string> collectors, | |
ILogger log) | |
{ | |
collectors.Add(Serialize(new ExecuteSomeCommand(Guid.NewGuid().ToString()))); | |
} | |
private static string Serialize(ExecuteSomeCommand command) | |
{ | |
return JsonConvert.SerializeObject(command, new JsonSerializerSettings | |
{ | |
TypeNameHandling = TypeNameHandling.All | |
}); | |
} | |
} | |
public class ExecuteSomeCommand | |
{ | |
public ExecuteSomeCommand(string id) | |
{ | |
Id = id; | |
} | |
public string Id { get; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment