Skip to content

Instantly share code, notes, and snippets.

@nikostoulas
Created September 9, 2021 08:05
Show Gist options
  • Save nikostoulas/0122542dbe7844541005450b61ed9751 to your computer and use it in GitHub Desktop.
Save nikostoulas/0122542dbe7844541005450b61ed9751 to your computer and use it in GitHub Desktop.
RPC example with backpressure, timeout and stop
const file = await rabbit.getReply(‘readFile’, {
correlationId,
headers: { backpressure: true, timeout: 1000 },
});
for await (const line of file) {
console.log(line);
process(line);
if(processingHasFinished()) {
// send stop signal to producer of the stream which is a different microservice
file.emit(rabbit.constructor.STOP_STREAM);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment