All Projects → apache → Rocketmq Client Nodejs

apache / Rocketmq Client Nodejs

Licence: apache-2.0
Apache RocketMQ nodejs client

Labels

Projects that are alternatives of or similar to Rocketmq Client Nodejs

Onemall
芋道 mall 商城,基于微服务的思想,构建在 B2C 电商场景下的项目实战。核心技术栈,是 Spring Boot + Dubbo 。未来,会重构成 Spring Cloud Alibaba 。
Stars: ✭ 5,312 (+3954.96%)
Mutual labels:  rocketmq
Rocketmq trans message
基于rocketmq上加入了事务消息的功能
Stars: ✭ 67 (-48.85%)
Mutual labels:  rocketmq
Springboot Labs
一个涵盖六个专栏:Spring Boot 2.X、Spring Cloud、Spring Cloud Alibaba、Dubbo、分布式消息队列、分布式事务的仓库。希望胖友小手一抖,右上角来个 Star,感恩 1024
Stars: ✭ 12,804 (+9674.05%)
Mutual labels:  rocketmq
Taoshop
开源电子商务项目,SpringBoot+Dubbo技术栈实现微服务,实现一款分布式集群的电商系统. 项目releases链接:https://github.com/u014427391/taoshop/releases (开发中...)
Stars: ✭ 491 (+274.81%)
Mutual labels:  rocketmq
Spring Boot Extend
在springboot基础上的扩展项目,快速集成Zookeeper、Dubbo、Apollo、Mybatis多数据源
Stars: ✭ 63 (-51.91%)
Mutual labels:  rocketmq
Rocketmq Spring
Apache RocketMQ Spring Integration
Stars: ✭ 1,281 (+877.86%)
Mutual labels:  rocketmq
Matecloud
🔥MateCloud是一款基于Spring Cloud Alibaba的微服务架构。目前已经整合Spring Cloud Alibaba、Spring Security Oauth2、Feign、Dubbo、JetCache、RocketMQ等服务套件,为您的开发保驾护航
Stars: ✭ 412 (+214.5%)
Mutual labels:  rocketmq
Distributed framework
python通用分布式函数调度框架 pip install function_scheduling_distributed_framework
Stars: ✭ 123 (-6.11%)
Mutual labels:  rocketmq
Eshop Soa
EShop基于Dubbo实现SOA服务化拆分,并基于RocketMQ解决了分布式事务(新版SpringBootSOASkeleton)
Stars: ✭ 65 (-50.38%)
Mutual labels:  rocketmq
Flink Learning
flink learning blog. http://www.54tianzhisheng.cn/ 含 Flink 入门、概念、原理、实战、性能调优、源码解析等内容。涉及 Flink Connector、Metrics、Library、DataStream API、Table API & SQL 等内容的学习案例,还有 Flink 落地应用的大型项目案例(PVUV、日志存储、百亿数据实时去重、监控告警)分享。欢迎大家支持我的专栏《大数据实时计算引擎 Flink 实战与性能优化》
Stars: ✭ 11,378 (+8585.5%)
Mutual labels:  rocketmq
Javafamily
【Java面试+Java学习指南】 一份涵盖大部分Java程序员所需要掌握的核心知识。
Stars: ✭ 28,668 (+21783.97%)
Mutual labels:  rocketmq
Springbootexamples
Spring Boot 学习教程
Stars: ✭ 794 (+506.11%)
Mutual labels:  rocketmq
Springboot Templates
springboot和dubbo、netty的集成,redis mongodb的nosql模板, kafka rocketmq rabbit的MQ模板, solr solrcloud elasticsearch查询引擎
Stars: ✭ 100 (-23.66%)
Mutual labels:  rocketmq
Gofamily
🔥 大厂 BAT 面试高频知识点,后端技术体系。包含了 C GO Python, 网络,Redis ,MySQL ,消息队列 ,高并发,微服务,缓存,操作系统,算法,LeetCode 刷题等知识
Stars: ✭ 474 (+261.83%)
Mutual labels:  rocketmq
Myth
Reliable messages resolve distributed transactions
Stars: ✭ 1,470 (+1022.14%)
Mutual labels:  rocketmq
Cookbook
🎉🎉🎉JAVA高级架构师技术栈==任何技能通过 “刻意练习” 都可以达到融会贯通的境界,就像烹饪一样,这里有一份JAVA开发技术手册,只需要增加自己练习的次数。🏃🏃🏃
Stars: ✭ 428 (+226.72%)
Mutual labels:  rocketmq
Paascloud Master
spring cloud + vue + oAuth2.0全家桶实战,前后端分离模拟商城,完整的购物流程、后端运营平台,可以实现快速搭建企业级微服务项目。支持微信登录等三方登录。
Stars: ✭ 9,194 (+6918.32%)
Mutual labels:  rocketmq
Xc Spring Cloud Alibaba
spring cloud alibaba(2.2.1最新版)+nacos+dubbo+gateWay+sentinel+rocketmq+(pgsql/mysql8.0的json支持)+ignite集成可用于docker分布式框架+分布式自动化任务+mybatis多数据源+seate+ shardingSphere分布式分库事务解决方案
Stars: ✭ 131 (+0%)
Mutual labels:  rocketmq
Rocketmq Exporter
Apache RocketMQ Prometheus Exporter
Stars: ✭ 123 (-6.11%)
Mutual labels:  rocketmq
Whatsmars
Java生态研究(Spring Boot + Redis + Dubbo + RocketMQ + Elasticsearch)🔥🔥🔥🔥🔥
Stars: ✭ 1,389 (+960.31%)
Mutual labels:  rocketmq

RocketMQ Client for Node.js

Version Downloads License TravisCI Dependency

This official Node.js client is a lightweight wrapper around rocketmq-client-cpp, a finely tuned CPP client.

Notice 1: This client is still in dev version. Use it cautiously in production.

Notice 2: This SDK is now only support macOS and Ubuntu 14.04. Ubuntu 16+ is not supported and CentOS is not tested yet.

Installation

$ npm install --save apache-rocketmq

Examples

You may view example/producer.js and example/push_consumer.js for quick start.

Usage

Require this package first.

const { Producer, PushConsumer } = require("apache-rocketmq");

Producer

Constructor

new Producer(groupId[, instanceName][, options]);

Producer's constructor receives three parameters:

  • groupId: the group id of the producer;
  • instanceName: the instance name of the producer, optional;
  • options: the options object, optional;
    • nameServer: the name server of RocketMQ;
    • groupName: the group name of this producer;
    • compressLevel: the compress level (0-9) of this producer, default to 5 where 0 is fastest and 9 is most compressed;
    • sendMessageTimeout: send message timeout millisecond, default to 3000 and suggestion is 2000 - 3000ms;
    • maxMessageSize: max message size with unit (B), default to 1024 * 128 which means 128K;
    • logFileNum: C++ core logic log file number, default to 3 and log file path is $HOME/logs/rocketmq-cpp;
    • logFileSize: size of each C++ core logic log file with unit (B);
    • logLevel: C++ core logic log level in "fatal", "error", "warn", "info", "debug", "trace" and "num".

e.g.

const { Producer } = require("apache-rocketmq");
const producer = new Producer("GROUP_ID", "INSTANCE_NAME", {
    nameServer: "127.0.0.1:9876",
});

start

producer.start([callback]);

.start receives a callback function. If no callback passed, this function will return a Promise object.

e.g.

producer.start(function(err) {
    if(err) {
        //
    }
});

// or

producer.start().then(() => {
    //
}).catch(err => {
    //
});

shutdown

producer.shutdown([callback]);

.shutdown receives a callback function. If no callback passed, this function will return a Promise object.

e.g.

producer.shutdown(function(err) {
    if(err) {
        //
    }
});

// or

producer.shutdown().then(() => {
    //
}).catch(err => {
    //
});

send

producer.send(topic, body[, options][, callback]);

.send receives 4 parameters including a callback. If no callback passed, this function will return a Promise object.

  • topic: the topic string;
  • body: the message body string;
  • options: the options object, optional;
    • keys: the keys for this message;
    • tags: the tags for this message;
  • callback: the callback function, optional.

e.g.

producer.send("test", `baz ${i}`, {
    keys: "foo",
    tags: "bar"
}, function(err, result) {
    if(err) {
        // ...    
    } else {
        console.log(result);

        // console example:
        //
        //  { status: 0,
        //    statusStr: 'OK',
        //    msgId: '0101007F0000367E0000309DD68B0700',
        //    offset: 0 }
    }
});
send status and statusStr
status statusStr
0 OK
1 FLUSH_DISK_TIMEOUT
2 FLUSH_SLAVE_TIMEOUT
3 SLAVE_NOT_AVAILABLE

PushConsumer

Constructor

new PushConsumer(groupId[, instanceName][, options]);

PushConsumer's constructor receives three parameters:

  • groupId: the group id of the push consumer;
  • instanceName: the instance name of the push consumer, optional;
  • options: the options object, optional;
    • nameServer: the name server of RocketMQ;
    • threadCount: the thread number of underlying C++ logic;
    • maxBatchSize: message max batch size;
    • logFileNum: C++ core logic log file number, default to 3 and log file path is $HOME/logs/rocketmq-cpp;
    • logFileSize: size of each C++ core logic log file with unit (B);
    • logLevel: C++ core logic log level in "fatal", "error", "warn", "info", "debug", "trace" and "num".

e.g.

const { PushConsumer } = require("apache-rocketmq");
const consumer = new PushConsumer("GROUP_ID", "INSTANCE_NAME", {
    nameServer: "127.0.0.1:9876",
    threadCount: 3
});

start

consumer.start([callback]);

.start receives a callback function. If no callback passed, this function will return a Promise object.

e.g.

consumer.start(function(err) {
    if(err) {
        //
    }
});

// or

consumer.start().then(() => {
    //
}).catch(err => {
    //
});

shutdown

consumer.shutdown([callback]);

.shutdown receives a callback function. If no callback passed, this function will return a Promise object.

e.g.

consumer.shutdown(function(err) {
    if(err) {
        //
    }
});

// or

consumer.shutdown().then(() => {
    //
}).catch(err => {
    //
});

subscribe

Add a subscription relationship to consumer.

consumer.subscribe(topic[, expression]);

.subscribe receives two parameters which the second parameter is optional.

  • topic: The topic to be subscribed;
  • expression: The additional expression to be subscribed, optional. e.g. *.

On Message Event

If you want to receive messages from RocketMQ Server, you should add a listener for message event which receives 2 parameters.

function YOUR_LISTENER(msg, ack) {
    //
}
  • msg: the message object to be consumed;
  • ack: the Acknowledge object, which has a .done() function.

msg object looks like:

{ topic: 'test',
  tags: 'bar',
  keys: 'foo',
  body: 'baz 7',
  msgId: '0101007F0000367E0000339DD68B0800' }

You may call ack.done() to tell RocketMQ that you've finished your message successfully which is same as ack.done(true). And you may call ack.done(false) to tell it that you've failed.

e.g.

consumer.on("message", function(msg, ack) {
    console.log(msg);
    ack.done();
});

Apache RocketMQ Community

Contact Us

How to Contribute

Contributions are warmly welcome! Be it trivial cleanup, major new feature or other suggestion. Read this how to contribute guide for more details.

License

Apache License, Version 2.0 Copyright (C) Apache Software Foundation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].