1.4.1 • Published 2 years ago

@galenjs/amqp-next v1.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

amqp-next

TODO: description

Usage

install

yarn add @galenjs/amqp-next
// or
npm i @galenjs/amqp-next
// or
pnpm install @galenjs/amqp-next
  • original
// app.js
const Amqp = require('./index')

const amqp = new Amqp({
  config: {
    url: 'amqp://localhost:5672',
    sub: {
      test: {
        pullInterval: 1000, // 默认1s拉一次消息
        pullBatchSize: 5, // 每次拉5条
        topic: 'GALEN' // topic
      }
    },
    consumerPath: `${process.cwd()}/test`
  },
  logger: console
})

const start = async () => {
  await amqp.setup()
}

start()

setInterval(async () => {
  /**
   * topic
   * routeKey
   * content
   * options
  */
  await amqp.send('GALEN', 'test', 'hello world')
}, 10000)
// test/test.js
module.exports = class Test {
  async onMsg (msg) {
    console.log('[message]: ', msg)
  }
}
  • support galenjs framework app and context
// app.js
const Amqp = require('./index')

const amqp = new Amqp({
  config: {
    url: 'amqp://localhost:5672',
    sub: {
      test: {
        pullInterval: 1000, // 默认1s拉一次消息
        pullBatchSize: 5, // 每次拉5条
        topic: 'GALEN' // topic
      }
    },
    consumerPath: `${process.cwd()}/test`
  },
  logger: console,
  app
})

const start = async () => {
  await amqp.setup(ctx)
}

start()
1.3.4

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.1.10

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago