coryvirok commented on issue #133:
URL:
https://github.com/apache/pulsar-client-node/issues/133#issuecomment-733844778
Correct. Thanks for clarifying the roadmap. I'll give it some thought to see
if I can think of any ways to make this more idiomatic without having to change
the C++ core.
My current workaround is to pass in an EventEmitter to the function that
executes the `receive(timeout)` loop and to check if it has fired before
continuing the loop.
E.g.
```js
async function doWork(shutdownEvent) {
let isShuttingDown = false;
const consumer = await pulsarClient.subscribe({
topic: `test`,
subscription: "default",
});
shutdownEvent.once('close', () => {
isShuttingDown = true;
});
while (!isShuttingDown) {
try {
// Since receive() is blocking, use this version in order to give up
control and allow
// the while loop to check if it should finish.
await consumer.receive(1000);
console.log("received message");
} catch (e) {
// ...
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]