-
Notifications
You must be signed in to change notification settings - Fork 0
Subscribe General Message
Jefferson Medeiros edited this page Apr 28, 2020
·
3 revisions
Parameters:
-
routingKey: string- Defines the rule that will be used by the exchange to perform message routing; -
callback: (message: any) => void- Function that will be executed when a message is directed by the exchange to the current subscribe;
Return:
-
Promise<void>- Promise will not return anything if the subscription to the event was successful. In case of an error, an exception will be returned.
sub(routingKey: string, callback: (message: any) => void): Promise<void>Example of use:
import { IOcariotRabbitMQClient, OcariotRabbitMQClient } from "@ocariot/rabbitmq-client-node"
const ocariot: IOcariotRabbitMQClient = new OcariotRabbitMQClient("Target Microservice Name")
function subCallback(message) {
console.log(message)
}
ocariot.sub("routkey.message", subCallback)OCARIoT RabbitMQ Client Library (Full documentation)