# Kotlin coroutines and SharedFlow

**URL:** <https://forum.inductiveautomation.com/t/kotlin-coroutines-and-sharedflow/108913>\
**Category:** Module Development\
**Created:** [July 24, 2025, 4:56pm UTC](https://forum.inductiveautomation.com/t/kotlin-coroutines-and-sharedflow/108913 "2025-07-24T16:56:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cos](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cos/32/66963_2.png) [@cos](https://forum.inductiveautomation.com/u/cos)\
**Post date:** [July 24, 2025, 4:56pm UTC](https://forum.inductiveautomation.com/t/kotlin-coroutines-and-sharedflow/108913/1 "2025-07-24T16:56:25Z")

</div>

Is anyone using [coroutines and SharedFlow](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/)?

Or will we better off sticking with [execution managers](https://www.sdk-docs.inductiveautomation.com/docs/programming-for-the-gateway/working-with-platform-services/#creating-private-execution-managers)?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/5/b57b8dc7ac27ee7535c59f701532edb6f1274804.png)

Any tips or examples for a module that needs to await tcp messages and _do something_™ when there is new data?

I've seen [this nice SSE example](https://github.com/mussonindustrial/embr/blob/00be9caeca27cfc86992baf3abe7008153c5763f/modules/sse/gateway/src/main/kotlin/com/mussonindustrial/embr/sse/EventStreamGatewayContext.kt).

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 24, 2025, 5:55pm UTC](https://forum.inductiveautomation.com/t/kotlin-coroutines-and-sharedflow/108913/2 "2025-07-24T17:55:26Z")

</div>

If you're in a Kotlin context and know what you're doing, feel free to use coroutines across whatever dispatcher(s) you want. Our first-party OPC UA module uses Kotlin and coroutines heavily.

Even from a Java context, I'd generally recommend folks use standard `Executors` over our first-party execution managers.
