amqpimping

Pimp my AMQP

AMQPimping

AMQPimping is a simple wrapper around the amqplib module. You can use it, for example, to listen and publish messages to RabbitMQ.

Features

  • Event-emitting class
  • Reuse AMQP connection and channel
  • Reconnect to queue / channel on disconnections and errors
  • Retry mechanism with on bluebird-retry
  • bunyan integration

Example usage

----- ----- ------- ---- -

    ------------- ------ -- -
        -------
            ----- ------------
            --------- ---------------
            --------- ---------------
            ------- --------------------- ----- ------- ---
            ------ -
                --------- ---
                --------- -----
                -------- -
            -
        ---
    -
-

----- ----- - --- ------- ------ ---

-- ---- ---- --- ------ -- --- ----- ------ ----- --------------

------------------- -- -- -
    -- ---- ---------- -- --- ----- --------- -- ------
    ---------------------------
---

------------------ -- -- -
    ---------------------- -------- ---- ------------

    ---------------------------------- ---- --- - ---- -------

    -------------
---

-- ----- --- -----
--------------

API

new AMQP(options)

Constructor of the AMQP listener.

Param Type Description
options object Options object.
options.host string The AMQP host to connect to.
options.username string The AMQP username.
options.password string The AMQP password.
options.logger function A bunyan logger instance.
options.retry object Retry settings.
options.retry.maxTries number Amount of retries.
options.retry.interval number Interval between retries.
options.retry.backoff number Backoff factor.
options.durable boolean Whether to use durable queues or not.

amqp.start()

Start the fun.

Kind: instance method of AMQP

amqp.connect()

Connect to AMQP.

Kind: instance method of AMQP

amqp.getChannel() ⇒ Promise

Gets the channel for this instance, or create a new one if it doesn't exist yet.

Kind: instance method of AMQP Returns: Promise - A promise to a AMQP channel.

amqp.createChannel() ⇒ Promise

Creates a new channel and handles all possible disconnections.

Kind: instance method of AMQP Returns: Promise - A promise to a AMQP channel.

amqp.listen(queue)

Listen to a queue.

Kind: instance method of AMQP

Param Type Description
queue string Name of the queue to listen to.

amqp.publish(queue, message)

Publish a message.

Kind: instance method of AMQP

Param Type Description
queue string Queue to publish the message to.
message string The message to publish.

amqp.stop()

Stop the AMQP listener. Connection with AMQP, if present, will be closed.

Kind: instance method of AMQP

"connect"

Event fired when the connection to AMQP is successful.

Kind: event emitted by AMQP

"message"

Event fired when a message is received in the queue.

Kind: event emitted by AMQP

"listen"

Event fired when the instance starts listening to messages in the queue.

Kind: event emitted by AMQP

"error"

Event fired when an error occurs.

Kind: event emitted by AMQP

"close"

Event fired when the connection to AMQP is closed.

Kind: event emitted by AMQP

Testing

Run the integration tests with npm test. You'll need docker compose to be installed.

License

See LICENSE.

HomePage

https://github.com/Dunkelheit/amqpimping#readme

Repository

git+https://github.com/Dunkelheit/amqpimping.git

来源:JavaScript中文网 ,转载请联系管理员! 本文地址:https://www.javascriptcn.com/post/60056cd381e8991b448e6643


猜你喜欢

  • npm 包 get-random-quote 使用教程

    在前端开发中,我们常常需要引用一些外部的库和插件来帮助我们实现各种功能。而在 npm 包库中,有很多优秀的开源项目可以供我们使用,例如 get-random-quote 就是一个常用的获取随机名言警句...

    3 年前
  • npm包immutable-shuffle使用教程

    本教程介绍如何使用npm包immutable-shuffle。该包提供了shuffle函数,可用于不可变数据结构数组的随机打乱操作。这对于前端开发中的一些交互效果非常有用,例如轮播图、随机加载等。

    3 年前
  • npm包 ireal-renderer 使用教程

    随着Web应用程序的普及,面向前端的技术也越来越受到重视。npm 是 JavaScript 世界的包管理器,它提供了大量的库和框架给前端工程师使用。其中一个受欢迎的 npm 包是 ireal-rend...

    3 年前
  • npm 包 props2json-webpack-plugin 使用教程

    前言 在前端开发中,我们经常使用到 webpack 进行代码打包构建。而在构建过程中,我们可能会需要对一些特殊的文件进行处理。比如:自定义配置文件、多语言翻译文件等等。

    3 年前
  • npm 包 comment-counts 使用教程

    引言 在前端开发中,我们经常需要展示一些带有评论的内容,比如文章、视频等等。如何展示一个页面中评论的数量呢?这时候我们可以使用 npm 包 comment-counts 来轻松地完成此项功能。

    3 年前
  • npm 包 clmtrackr-smile-recognition 使用教程

    简介 clmtrackr-smile-recognition 是一个基于 clmtrackr 的 JavaScript 库,它可以通过识别人脸的各种表情来实现深度学习。

    3 年前
  • npm 包 hapi-tracer 使用教程

    在前端开发中,日志记录和分析是非常重要的一项任务。 hapi-tracer 是一个基于 Hapi.js 框架的轻量级日志记录器,它可以帮助我们快速生成、保存和分析日志数据。

    3 年前
  • npm 包 nightwatch-base-page 使用教程

    引言 在前端开发中,我们经常需要编写测试用例以确保代码的正确性与稳定性,因此测试框架和工具也非常重要。在这方面,nightwatch.js 是一个常用的自动化测试框架,但是在编写 nightwatch...

    3 年前
  • npm 包 kintone-api-client 使用教程

    在前端开发中,kintone 是一款十分优秀的 SaaS(软件即服务) 全功能网站。它具有强大的前端扩展能力,使得开发者可以很容易地进行开发工作。本文将介绍如何使用 npm 包 kintone-api...

    3 年前
  • npm 包 tiki-spec 使用教程

    简介 tiki-spec 是一个 npm 包,用于帮助前端开发人员快速编写并运行测试用例。它采用了 TDD (测试驱动开发)的理念,可以有效提高项目的质量和开发效率。

    3 年前
  • npm 包 react-imp-tree 使用教程

    简介 React-imp-tree 是一款基于 React 的递归树组件,支持单选、复选、异步加载等功能。该组件具有良好的可扩展性,易于定制样式,提供丰富的 API 接口。

    3 年前
  • npm 包 @exogen/graphql-tools 使用教程

    前言 GraphQL 是一种由 Facebook 开发的数据查询语言,它提供了一种类似 RESTful API 的结构化数据传输方式。GraphQL 可以根据客户端的需要一次性查询多个资源,避免了 R...

    3 年前
  • npm 包 react-jsonschema-form-ungp 使用教程

    在前端开发中,我们常常需要使用表单组件来收集用户输入的数据。而 react-jsonschema-form-ungp 正是一个帮助我们更便捷的使用表单组件的工具包。

    3 年前
  • npm 包 responsivevoice 使用教程

    在现代前端开发中,使用语音合成技术给用户提供更好的使用体验是极具创意和实用的。而其中一个最流行的语音合成库就是 responsivevoice。 本文将向您介绍 npm 包 responsivevoi...

    3 年前
  • npm 包 admanic-ui-2 使用教程

    admanic-ui-2 是一个基于 React 和 Material-UI 的 UI 库,它提供了一系列常用的组件,如文本框、按钮、表格等。本教程将介绍如何在前端项目中使用此 npm 包,并提供相应...

    3 年前
  • npm 包 xcbanner 使用教程

    简介 xcbanner 是一款基于 React 构建的通用 Banner 组件,支持自定义样式和内容,提供丰富的配置项和 API 接口。 安装 在项目根目录下使用 npm 安装 xcbanner: -...

    3 年前
  • NPM 包 rae-lite 使用教程

    RAE-lite 是一款在前端开发中用于解析英汉字典数据的 npm 包,它支持多种语言、拼音及简体繁体中文等。在本文中,我们将探讨如何安装、使用以及深入理解这个 npm 包。

    3 年前
  • npm 包 microdsl 的使用指南

    什么是 microdsl? microdsl 是一款基于 JavaScript 的 DSL(领域特定语言)库,可以帮助开发者快速创建自己的 DSL。通过 microdsl,开发者可以使用类似 YAML...

    3 年前
  • npm 包 validator-restify 使用教程

    什么是 validator-restify validator-restify 是一个基于 node-validator 的 Restify 中间件,用于验证 HTTP 请求的参数。

    3 年前
  • npm 包 tw-cli 使用教程

    什么是 tw-cli tw-cli 是一个轻量级的命令行工具,其目的是针对移动端开发者提供一个方便的调试和测试环境。该工具可以快速创建 HTTP 服务器,支持热重载和代理功能,并且可以通过自定义配置文...

    3 年前

相关推荐

    暂无文章