Skip to content

Conversation

@Ozoniuss
Copy link

This example shows how you can use Temporal's event history and workflow input as a queue. It implements a batching mechanism where a workflow continuously listens for incoming signals, as well as a timer, and processes the batch when the timer fires, followed by restarting the timer. The workflow keeps track of the number of incoming events and decides to continue-as-new when there are too many events recorded in the event history, passing the accumulated events in the next workflow's input.

What was changed

Added a new example.

Depending on how complicated the change is, I think it may be worth it to add a Ticker to the workflow API (e.g. workflow.NewTicker) since we already also have Timer. I think it would at least be a nice addition to the Go SDK (implemented with Timers), if not worthy as a Temporal feature.

Why?

This seemed to be a nice pattern in situations where you need some sort of queue to batch operations, but you only have a Temporal cluster available and no event streaming platform. It likely doesn't reach the same performance as say Kafka for extremely high throughput, but it should be good enough for a large amount of use-cases.

I needed to write a similar PoC, so I thought I'd share it here as well.

Checklist

  1. How was this tested:
    Local Temporal cluster, also explained in readme.

This example shows how you can use Temporal's event history and workflow
input as a queue. It implements a batching mechanism where a workflow
continuously listens for incoming signals, as well as a timer, and
processes the batch when the timer fires, followed by restarting the
timer. The workflow keeps track of the number of incoming events and
decides to continue-as-new when there are too many events recorded in
the event history, passing the accumulated events in the next workflow's
input.
@Ozoniuss Ozoniuss requested a review from a team as a code owner October 18, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant