Repository navigation
CxODEV-2125: keep the Kafka cancellation consumer running after a bad message (4.4.2) - #229
Closed
milansvitlica-codaxy wants to merge 1 commit into
Closed
milansvitlica-codaxy wants to merge 1 commit into
milansvitlica-codaxy wants to merge 1 commit into
Conversation
The consume loop sat inside a single try/catch. When one message failed, the catch logged "will retry to consume after 5 seconds", waited, and then ExecuteAsync returned. The consumer never restarted, so the worker kept running but stopped cancelling tasks until the process restarted. Two kinds of message trigger it: - the handler throws, e.g. a status event with "workflowTask": null (NullReferenceException on WorkflowTask.Type); - the value fails to deserialize (invalid or empty JSON, an unknown status, a workflowTask without name or taskReferenceName), so Consume throws a ConsumeException. Errors are now caught per message: logged, and the loop moves on to the next message. OperationCanceledException from the stopping token still ends the loop, so shutdown is unchanged. The 5-second pause is gone. It only ran once before the loop exited, and pausing on every bad message would hold up every cancellation behind it. Tests run the real consumer against librdkafka's in-process mock cluster (test.mock.num.brokers), so they need no broker or Docker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Closing without merging: not pursuing this change for now. |
milansvitlica-codaxy
deleted the
CxODEV-2125-kafka-notifier-skip-bad-messages
branch
October 9, 2026 08:41
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
KafkaConsumerBackgroundServiceruns its consume loop inside one try/catch. When a single message fails, the catch logs "will retry to consume after 5 seconds", waits, andExecuteAsyncreturns. Nothing restarts the consumer. The worker keeps running, but it stops cancelling tasks until the process restarts.Two kinds of message trigger this:
"workflowTask": nullmakesHandleKafkaEventthrow aNullReferenceExceptiononWorkflowTask.Type.status, or aworkflowTaskwithoutnameortaskReferenceName(both areRequired.Alwayson the generated model).Consumethen throws aConsumeException.Fix
OperationCanceledExceptionfrom the stopping token still ends the loop, so shutdown is unchanged.InternalsVisibleTo("ConductorSharp.Engine.Tests")to the notifier assembly, asConductorSharp.Enginealready does.Tests
New
KafkaCancellationNotifierTestsrun the real consumer and notifier against librdkafka's in-process mock cluster (test.mock.num.brokers). No broker or Docker is needed.CancelsTaskAfterUnprocessableMessage:"workflowTask": null, then a CANCELED eventCancelsTaskAfterUnprocessableMessage:not json, then a CANCELED eventStopAsyncEndsConsumptionStopAsyncEndsConsumptionguards shutdown. It fails if the per-message catch also swallowsOperationCanceledException; I checked this by applying that change.Full suite,
dotnet test ConductorSharp.sln: 76 passed, 0 failed. Run locally on the .NET 8 runtime (DOTNET_ROLL_FORWARD=Major); CI runs it on .NET 6.Note for local runs on Windows with
core.autocrlf=true: 30 JSON fixture tests already fail onmasterthere (CRLF fixtures vs LF output). The run above used an LF checkout, like CI.Backport to
v3: #230 (3.10.1).🤖 Generated with Claude Code