Skip to content

BUG: cannot borrow channels when inside worker threads #245

@m6-khangdm

Description

@m6-khangdm

First of all, thank you for the library. I'm not sure if this is a bug, will make changes later if needed.

Description

When using rascal with worker threads, everything seems to work fine in the main thread but in worker thread it just hangs at borrowing channels. I'm not even sure if this is the right way, because it seems that for each worker thread a new connection and new channel pools are created, and channel pools cannot be shared between connections.

Inside the main thread:

rascal:Vhost Initialising vhost: / +0ms
rascal:Vhost Creating regular channel pool { autostart: false, max: 5, min: 1, evictionRunIntervalMillis: 10000, idleTimeoutMillis: 60000, rejectionDelayMillis: 1000, testOnBorrow: true, acquireTimeoutMillis: 15000, destroyTimeoutMillis: 1000 } +284ms
rascal:Vhost Creating confirm channel pool { autostart: true, max: 5, min: 1, evictionRunIntervalMillis: 10000, idleTimeoutMillis: 60000, rejectionDelayMillis: 1000, testOnBorrow: true, acquireTimeoutMillis: 15000, destroyTimeoutMillis: 1000 } +1ms
rascal:Vhost Creating pooled confirm channel for vhost: / +0ms
rascal:Vhost vhost: / was initialised with connection: 655c5d77-3e88-479e-bf30-12d6e95ad99d +1ms
rascal:Vhost Created confirm channel: dd96545d-24ed-48a7-be28-d4af160e3923 from connection: 655c5d77-3e88-479e-bf30-12d6e95ad99d +46ms
rascal:Vhost Requested confirm channel. { vhost: '/', mode: 'confirm', queue: 0, size: 1, available: 1, borrowed: 0, min: 1, max: 5 } +969ms
rascal:Vhost Borrowed confirm channel: dd96545d-24ed-48a7-be28-d4af160e3923. { vhost: '/', mode: 'confirm', queue: 0, size: 1, available: 0, borrowed: 1, min: 1, max: 5 } +2ms

Inside a worker thread:

2026-02-05T06:11:40.435Z rascal:Vhost Creating regular channel pool { autostart: false, max: 5, min: 1, evictionRunIntervalMillis: 10000, idleTimeoutMillis: 60000, rejectionDelayMillis: 1000, testOnBorrow: true, acquireTimeoutMillis: 15000, destroyTimeoutMillis: 1000 }
2026-02-05T06:11:40.436Z rascal:Vhost Creating confirm channel pool { autostart: true, max: 5, min: 1, evictionRunIntervalMillis: 10000, idleTimeoutMillis: 60000, rejectionDelayMillis: 1000, testOnBorrow: true, acquireTimeoutMillis: 15000, destroyTimeoutMillis: 1000 }
2026-02-05T06:11:40.436Z rascal:Vhost Creating pooled confirm channel for vhost: /
2026-02-05T06:11:40.437Z rascal:Vhost vhost: / was initialised with connection: 307da5bb-dd82-4f8a-8a02-6a37dfa41daa
2026-02-05T06:11:40.443Z rascal:Vhost Requested confirm channel. { vhost: '/', mode: 'confirm', queue: 0, size: 1, available: 0, borrowed: 0, min: 1, max: 5 }
2026-02-05T06:11:40.734Z rascal:Vhost Requested confirm channel. { vhost: '/', mode: 'confirm', queue: 0, size: 1, available: 0, borrowed: 0, min: 1, max: 5 }
2026-02-05T06:11:40.735Z rascal:Vhost Requested confirm channel. { vhost: '/', mode: 'confirm', queue: 1, size: 1, available: 0, borrowed: 0, min: 1, max: 5 }

Expected Behavior

rascal should be able to borrow channels in worker threads.

Actual Behavior

rascal does not seem to be able to borrow any channel in worker threads.

Steps to Reproduce

  1. Create rascal broker and publish a message in the main thread
  2. Spawn a worker thread
  3. Create rascal broker and publish a message in the worker thread

Context

Basically I'm trying to use rascal with breejs (a task scheduler for nodejs) but not successful so far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions