@zeroq/amqp-wrapper
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

ZeroQ AMPQ wrapper

Usage

import * as broker from "@zeroq/amqp-wrapper"

//first connect to amqp server (rabbitmq)
await broker.connect( 
  connString, 
  { 
    name: "offices", //exchange name
    type: "topic"    //exchange type
  }, 
  true, //if true create a channel for subscribers
  true, //if true create a channel for publisher
)
  
//if createChannelSubsriber is true, then you can add subscribers
  const subscriber = await broker.addSubscriber(
    "queue_name", 
    "#.route.key",
    {
      name: "offices", //exchange name
      type: "topic"    //exchange type
    },
  );

//now you can listen messages 
attentionsSubscriber.listen(async (content) => {
  // the listen function do the ack() or nack() when is an error
  //use the try/catch block
  try{
    //do your logic here
  }catch (e) {
    throw e
  }
})

//to publish messages it's required createPublisherChannel in true in connect function
await broker.publish(
  'zeroq.route.key', //check this link to review the routink key format https://www.notion.so/zeroq/Formato-de-colas-y-routing-keys-de-broker-1669f3dd032c4717817395074e48c4f3#719d4f95e78e4e49a82b923670c1be30
  {
    key:"data"
  } //an object with the message to send
)

/@zeroq/amqp-wrapper/

    Package Sidebar

    Install

    npm i @zeroq/amqp-wrapper

    Weekly Downloads

    5

    Version

    1.2.4

    License

    none

    Unpacked Size

    31.8 kB

    Total Files

    29

    Last publish

    Collaborators

    • cvallenilla