Esempio n. 1
0
        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}");
            }
        }
Esempio n. 2
0
        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!");
                }
            }));
        }
Esempio n. 3
0
 public void TriggerTaskUpdate(SDETask task)
 {
     onTaskUpdateHook(task);
 }
Esempio n. 4
0
 public void TriggerTaskCreated(SDETask task)
 {
     onTaskCreateHook(task);
 }