@topcreator/rabbit_mq_lib
v1.0.49
Published
A common library for RabbitMQ interactions
Downloads
1,967
Readme
RabbitMQ Library TC
A library to simplify interactions with RabbitMQ using TypeScript for microservices.
Installation
npm install @topcreator/rabbit_mq_lib
FTo use this library successfully, follow these steps:
Add an environment variable with the RabbitMQ connection URL - RABBITMQ_URL. In your project's initialization file (e.g., server.ts or index.ts), call the initializeRabbitMQ function. Here is an example:
await initializeRabbitMQ(
config.RABBITMQ_URL,
RabbitQueueNames.BFF,
handleRabbitMQRequests
);
- Write the handleRabbitMQRequests function. For example, you can use the following structure:
export const handleRabbitMQRequests = async (
message: RabbitMQMessage
): Promise<any> => {
switch (message.action) {
case RABBIT_SOCIAL_STAT_ACTIONS.createTrackingAccounts:
return createTrackingAccounts(message.data);
// here is you can to add another cases if you have
default:
return Promise.reject('Unknown action');
}
};
Contributing
Contributions are welcome! If you have any suggestions or questions, please, write to my GIT