public static void Run(string input, TraceWriter log)
{
log.Info("SimpleProducer");
KafkaOptions options = new KafkaOptions(new Uri("http://*******:9092"));
BrokerRouter router = new BrokerRouter(options);
Producer client = new Producer(router);
while(true)
{
JObject obj = JObject.FromObject(new
{
ExchangeName = "BitFinex",
CurrencyPair = "Dollar",
MachineTime = DateTime.Now.ToString("dd-MM-yyyy_HH:mm:ss.ffffff"),
OrderSide = "Buy",
OrderId = "123",
Price = "10",
Quantity = "100"
});
log.Info(obj.ToString(Formatting.None));
client.SendMessageAsync("tenant", new[] { new Message(obj.ToString(Formatting.None)) }).Wait();
log.Info("Next Iteration");
}
}
我用while while循環來在蔚藍天青功能中連續處理數據。但是azure函數在5到6分鐘後停止,我再次需要重新運行天藍色的函數。有沒有任何設置可以連續運行azure功能?我已經使用了上面的代碼。如何使天藍色的功能在5到6分鐘後停止運行?
Azure函數主要是事件驅動的,這意味着你需要一些東西來觸發函數(定時器,隊列,存儲等)。因此,這使得函數不適合你想要實現的功能。根據下面的答案,WebJobs更適合執行此任務 – Chris