private async void OnTaskUpdateHook(SDETask task) { Log.Information("Task Updated Event Received from Hook!"); try { var dr = await taskProducer.ProduceAsync(INGRESS_UPDATE_TOPIC_NAME, new Message <Ignore, SDETaskProto>() { Value = task }); Log.Information($"Task Updated message successfully delivered: '{dr.Value}' to '{dr.TopicPartitionOffset}'"); } catch (ProduceException <Null, string> e) { Log.Error($"Task Updated message delivery failed! {e.Error.Reason}"); } }
private Task StartTaskConsumer(CancellationToken ct) { return(Task.Factory.StartNew(async() => { Log.Information("Task Consumer listening ..."); try { while (true) { Log.Information("Waiting for Task message ..."); try { var taskMsg = taskConsumer.Consume(ct); SDETask sdeTask = null; if (taskMsg.Topic.Equals(CREATE_TOPIC_NAME)) { sdeTask = await integrationClient.CreateTask(taskMsg.Value); } else if (taskMsg.Topic.Equals(UPDATE_TOPIC_NAME)) { sdeTask = await integrationClient.UpdateTask(taskMsg.Value); } else if (taskMsg.Topic.Equals(REMOVE_TOPIC_NAME)) { sdeTask = await integrationClient.RemoveTask(taskMsg.Value); } if (sdeTask == null) { Log.Error($"Could not save issue for message: '{taskMsg.Value}' at: '{taskMsg.TopicPartitionOffset}'"); // do something more with this than just error (dead-letter queue?) } taskConsumer.StoreOffset(taskMsg); Log.Information($"Consumed message '{taskMsg.Value}' at: '{taskMsg.TopicPartitionOffset}'."); } catch (ConsumeException e) { Log.Error($"Error occurred: {e.Error.Reason}"); } } } catch (OperationCanceledException) { // Ensure the consumer leaves the group cleanly and final offsets are committed. taskConsumer.Close(); Log.Information("Task Consumer closed!"); } })); }
public void TriggerTaskUpdate(SDETask task) { onTaskUpdateHook(task); }
public void TriggerTaskCreated(SDETask task) { onTaskCreateHook(task); }