3.0.1 • Published 7 months ago

inter-cluster-queue-manager-client v3.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

INTER-CLUSTER-QUEUE-MANAGER-CLIENT

This is a simple NodeJsClient to consume and publish from interClusterQueueManagerServer

How to use It ?

Initialize the consumer :

npm i inter-cluster-queue-manager-client
    const consumer  = new EventConsumer('http://127.0.0.1:3600',{});
Declere your CallBacks on events:
    consumer.on("error",(err)=>{
        console.error(err)
    })
    consumer.on("open",(e)=>{
        console.log(`Connection succussifly established`,e)
    })

    consumer.on("message",(msg)=>{
        // @example : {"type":"message","data":{"timestamp":"2023-02-18T11:24:44.679Z","event":{"user":"10"},"topic":"deals"},"lastEventId":"","origin":"http://127.0.0.1:3600"}
        console.log('new messsage',msg)
    })

Now you can start consuming from your topics:

    consumer.startConsumeFromTopics(["deals","notifications","etc..."]);

How to use publisher

The publisher is used to send event to topics

Initialize the publisher :

    const publisher = new EventPublisher('http://127.0.0.1:3600');

start to publish your events :

        try {
            await publisher.publish("deals", {
                user: +(Math.random() * 1000).toFixed(),
                status: "open",
                extra: {
                    boh: true
                }
            })


            console.log("Ok");

        } catch (err) {
            console.error("Error while sending event")
        }
3.0.1

7 months ago

3.0.0

7 months ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago