API: consumer
Source:
rabbitmq/consumer.ts
RabbitMQ Consumer
This facade provides static methods to start and stop listening on RabbitMQ queues, wrapping the underlying Java implementation provided by the RabbitMQFacade.
Usage
// --------
// start.ts
// --------
import { consumer } from "sdk/rabbitmq";
consumer.startListening("rabbitmq-queue", "my-rabbitmq-project/my-rabbitmq-handler");
// ----------------------
// my-rabbitmq-handler.ts
// ----------------------
exports.onMessage = function(message) {
console.log("Hello from My RabbitMQ Listener! Message: " + message);
};
exports.onError = function(error) {
console.error("Error from My RabbitMQ Listener! Error: " + error);
};
// -------
// stop.ts
// -------
import { consumer } from "sdk/rabbitmq";
consumer.stopListening("rabbitmq-queue", "my-rabbitmq-project/my-rabbitmq-handler");Classes
Consumer
RabbitMQ Consumer
This facade provides static methods to start and stop listening on RabbitMQ queues,
wrapping the underlying Java implementation provided by the RabbitMQFacade.
Methods
startListening
startListening (queue:string, handler:string):voidStarts listening for messages on a specified RabbitMQ queue.
The handler is typically a service or script URI that will be executed
when a message arrives.
@param queue The name of the RabbitMQ queue to listen to.
@param handler The URI/name of the component/script that will handle the message.
stopListening
stopListening (queue:string, handler:string):voidStops the message listener previously started on a specified RabbitMQ queue
for a given handler.
@param queue The name of the RabbitMQ queue.
@param handler The URI/name of the component/script whose listener should be stopped.