Created
September 9, 2021 08:05
-
-
Save nikostoulas/0122542dbe7844541005450b61ed9751 to your computer and use it in GitHub Desktop.
RPC example with backpressure, timeout and stop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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