Add ZMQ context customization

This commit is contained in:
Alexander Nozik 2023-07-23 14:29:26 +03:00
parent 6f5270ee37
commit 405bcd6ba3
2 changed files with 25 additions and 25 deletions

View File

@ -20,8 +20,9 @@ public class ZmqMagixEndpoint(
private val pubPort: Int = MagixEndpoint.DEFAULT_MAGIX_ZMQ_PUB_PORT,
private val pullPort: Int = MagixEndpoint.DEFAULT_MAGIX_ZMQ_PULL_PORT,
private val coroutineContext: CoroutineContext = Dispatchers.IO,
private val zmqContext: ZContext = ZContext()
) : MagixEndpoint, AutoCloseable {
private val zmqContext by lazy { ZContext() }
override fun subscribe(filter: MagixMessageFilter): Flow<MagixMessage> {
val socket = zmqContext.createSocket(SocketType.SUB)

View File

@ -24,8 +24,7 @@ public class ZmqMagixFlowPlugin(
scope: CoroutineScope,
receive: Flow<MagixMessage>,
sendMessage: suspend (MagixMessage) -> Unit,
): Job =
scope.launch(Dispatchers.IO) {
): Job = scope.launch(Dispatchers.IO) {
val logger = LoggerFactory.getLogger("magix-server-zmq")
ZContext().use { context ->