Coder Social home page Coder Social logo

rocketmq-client-nodejs's Introduction

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

rocketmq-client-nodejs's People

Contributors

duhengforever avatar duhenglucky avatar rickyes avatar shannonding avatar stu01509 avatar xadillax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rocketmq-client-nodejs's Issues

get 404 error when I download /linux/1.2.0/UBUNTU/5.04/librocketmq.a

What Happens?

[rocketmq sdk] [error] error status 404 while downloading [https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/linux/1.2.0/UBUNTU/5.04/librocketmq.a].
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

How to Reproduce

Steps to reproduce the behavior:

  1. npm install rocketmq-client-nodejs

Expected behavior

Context

  • Node Version: 10.x
  • SDK Version: 1.0.0-rc1
  • Platform: Debian

[Bug] Install Exception On Macosx

What Happens?

install error

Minimum Showcase (Required)

Provide a minimum code or GitHub repository which can reproduce the issue.
// node version: v12.16.2
npm i apache-rocketmq --rebuild

How to Reproduce

$ npm i apache-rocketmq --rebuild
> [email protected] install /Users/Arthur/FlyLab/examples/demo-rocketmq/node_modules/apache-rocketmq
> node ./script/download_lib.js && node-gyp rebuild

[rocketmq sdk] [info] downloading [https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/mac/1.2.0/librocketmq.dylib]...
[rocketmq sdk] [info] downloaded library [https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/mac/1.2.0/librocketmq.dylib].
[rocketmq sdk] [info] all libraries have been written to disk.
  CXX(target) Release/obj.target/rocketmq/src/rocketmq.o
../src/rocketmq.cpp:42:116: error: too few arguments to function call, single argument 'context' was not specified
    Nan::Set(target, Nan::New("macosDLOpen").ToLocalChecked(), Nan::New<v8::FunctionTemplate>(DLOpen)->GetFunction());
                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/Users/Arthur/Library/Caches/node-gyp/12.16.2/include/node/v8.h:6126:3: note: 'GetFunction' declared here
  V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
  ^
/Users/Arthur/Library/Caches/node-gyp/12.16.2/include/node/v8config.h:368:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
1 error generated.
make: *** [Release/obj.target/rocketmq/src/rocketmq.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/Arthur/FlyLab/examples/demo-rocketmq/node_modules/apache-rocketmq
gyp ERR! node -v v12.16.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm WARN @sevenryze/[email protected] requires a peer of @nestjs/common@^7.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN @sevenryze/[email protected] requires a peer of @nestjs/core@^7.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN @sevenryze/[email protected] requires a peer of reflect-metadata@^0.1.13 but none is installed. You must install peer dependencies yourself.
npm WARN @sevenryze/[email protected] requires a peer of rxjs@^6.5.4 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node ./script/download_lib.js && node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Steps to reproduce the behavior:

1.sudo n lts
2.npm i apache-rocketmq --rebuild

Expected behavior

install success

Context

  • Node Version: v12.16.2
  • SDK Version: 1.0.0-rc1
  • Platform: macos

can't install

What Happens?

run:
yarn add apache-rocketmq
got:

error An unexpected error occurred: "https://registry.npm.taobao.org/apache-rocketmq: Not found".

or run npm install --save apache-rocketmq got

npm ERR! code E404
npm ERR! 404 Not Found: apache-rocketmq@latest

Minimum Showcase (Required)

Provide a minimum code or GitHub repository which can reproduce the issue.

How to Reproduce

Steps to reproduce the behavior:

  1. yarn add apache-rocketmq or
  2. npm install --save apache-rocketmq or
  3. git clone && yarn add apache-rocketmq

Expected behavior

  1. can be installed

Context

  • Node Version:v8.14.0
  • SDK Version:latest commit
  • Platform:mac os 10.14.2 (18C54)

[Bug] Travis CI wget script error

What Happens?

Travis CI wget script error

Minimum Showcase (Required)

Provide a minimum code or GitHub repository which can reproduce the issue.

The wget http://us.mirrors.quenda.co/apache/rocketmq/4.3.2/rocketmq-all-4.3.2-bin-release.zip this link seems link has SSL certificate issue, and not found the file so that the Travis ci can't working normally.

install Exception On Window10

What Happens?

install error,I wonder is rocketmq-client-cpp.dll wrong?

Minimum Showcase (Required)

[email protected]
[email protected] | win32 | x64
python 2.7.15
npm 7.5.4

build/rocketmq.vcxproj's dependency ok~

<Link>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;&quot;C:\...\node.lib&quot;;D:\...\rocketmq-client-nodejs-master\deps\lib\rocketmq-client-cpp.lib</AdditionalDependencies>
</Link>

How to Reproduce

producer.obj : error LNK2001: 无法解析的外部符号 SetMessageBody
> [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetProducerSendMsgTimeout [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetProducerLogLevel [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SendMessageSync [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetMessageKeys [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetProducerMaxMessageSize [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetProducerLogFileNumAndSize [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 DestroyProducer [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetProducerNameServerAddress [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 CreateProducer [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetProducerCompressLevel [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 DestroyMessage [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetByteMessageBody [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 StartProducer [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 ShutdownProducer [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetMessageTags [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetProducerInstanceName [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 CreateMessage [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetProducerGroupName [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
producer.obj : error LNK2001: 无法解析的外部符号 SetProducerSessionCredentials [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
push_consumer.obj : error LNK2001: 无法解析的外部符号 SetPushConsumerNameServerAddress [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
push_consumer.obj : error LNK2001: 无法解析的外部符号 SetPushConsumerMessageBatchMaxSize [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
push_consumer.obj : error LNK2001: 无法解析的外部符号 SetPushConsumerSessionCredentials [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
push_consumer.obj : error LNK2001: 无法解析的外部符号 RegisterMessageCallback [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
push_consumer.obj : error LNK2001: 无法解析的外部符号 Subscribe [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
push_consumer.obj : error LNK2001: 无法解析的外部符号 GetMessageTags [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
push_consumer.obj : error LNK2001: 无法解析的外部符号 DestroyPushConsumer [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
push_consumer.obj : error LNK2001: 无法解析的外部符号 GetMessageId [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vcxproj]
cketmq-client-nodejs-master\build\rocketmq.vcxproj]
D:\worksplace\rocketmq-client-nodejs-master\build\Release\rocketmq.node : fatal error LNK1120: 38 个无法解析的外部命令 [D:\worksplace\rocketmq-client-nodejs-master\build\rocketmq.vq.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\Admin\AppData\Roaming\npm\node_modules\cnpm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.19042

Steps to reproduce the behavior:
-->cnpm install
Expected behavior
install success

Context

  • Node Version: 10.18.0
  • SDK Version: 1.0.0-rc1
  • Platform: window10

Can't compile with node12

What Happens?

CXX(target) Release/obj.target/rocketmq/src/rocketmq.o
../src/rocketmq.cpp:42:116: error: too few arguments to function call, single argument 'context' was not specified
Nan::Set(target, Nan::New("macosDLOpen").ToLocalChecked(), Nan::New<v8::FunctionTemplate>(DLOpen)->GetFunction());

image

Minimum Showcase (Required)

npm install --save apache-rocketmq with node v12

Context

  • Node Version: 12
  • SDK Version: latest
  • Platform: macos

[Feature Request] Support PutUserProperty

In java we can use message. putUserProperty to append some metadata into message, this is sometimes very useful, but in nodejs client we have not found how we can do this. Could you support this please?

Error: msg: No route info of this topic

  • Node Version: 10.15.1
  • SDK Version: "apache-rocketmq": "^1.0.0-rc1"
  • Platform: MacOS10.14.5

目前技术中台使用的是rocketmq4.0版本,使用"apache-rocketmq": "^1.0.0-rc1"接入后,尝试发送消息,得到以下报错:
'Error: msg: No route info of this topic, ,error:-1,in file </Users/liqipeng/gitDir/rocketmq-client-cpp-wlliqipeng/src/producer/DefaultMQProducer.cpp> line:319'

是否是"apache-rocketmq"使用的rocketmq版本比较高?想询问下,支持到rocketmq什么版本过?

../src/rocketmq.cpp:42:116: error: too few arguments to function call, single argument 'context' was not specified

npm ERR! code 1
npm ERR! path /Users/yunwisdom/Workspace/xdata/xdata-search-service/node_modules/apache-rocketmq
npm ERR! command failed
npm ERR! command sh -c node ./script/download_lib.js && node-gyp rebuild
npm ERR! [rocketmq sdk] [info] downloading [https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/mac/1.2.0/librocketmq.dylib]...
npm ERR! [rocketmq sdk] [info] downloaded library [https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/mac/1.2.0/librocketmq.dylib].
npm ERR! [rocketmq sdk] [info] all libraries have been written to disk.
npm ERR!   CXX(target) Release/obj.target/rocketmq/src/rocketmq.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info find Python using Python version 3.9.2 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/yunwisdom/Workspace/xdata/xdata-search-service/node_modules/apache-rocketmq/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/yunwisdom/Library/Caches/node-gyp/14.15.4/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/yunwisdom/Library/Caches/node-gyp/14.15.4',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/yunwisdom/Library/Caches/node-gyp/14.15.4/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/yunwisdom/Workspace/xdata/xdata-search-service/node_modules/apache-rocketmq',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! ../src/rocketmq.cpp:42:116: error: too few arguments to function call, single argument 'context' was not specified
npm ERR!     Nan::Set(target, Nan::New("macosDLOpen").ToLocalChecked(), Nan::New<v8::FunctionTemplate>(DLOpen)->GetFunction());
npm ERR!                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
npm ERR! /Users/yunwisdom/Library/Caches/node-gyp/14.15.4/include/node/v8.h:6482:3: note: 'GetFunction' declared here
npm ERR!   V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
npm ERR!   ^
npm ERR! /Users/yunwisdom/Library/Caches/node-gyp/14.15.4/include/node/v8config.h:431:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
npm ERR! #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
npm ERR!                               ^
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/rocketmq/src/rocketmq.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Darwin 20.1.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/yunwisdom/Workspace/xdata/xdata-search-service/node_modules/apache-rocketmq
npm ERR! gyp ERR! node -v v14.15.4
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/yunwisdom/.npm/_logs/2021-03-24T11_48_57_940Z-debug.log
yunwisdom@yunwisdom xdata-search-service % npm install --save apache-rocketmq
npm ERR! code 1
npm ERR! path /Users/yunwisdom/Workspace/xdata/xdata-search-service/node_modules/apache-rocketmq
npm ERR! command failed
npm ERR! command sh -c node ./script/download_lib.js && node-gyp rebuild
npm ERR! [rocketmq sdk] [info] downloading [https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/mac/1.2.0/librocketmq.dylib]...
npm ERR! [rocketmq sdk] [info] downloaded library [https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/mac/1.2.0/librocketmq.dylib].
npm ERR! [rocketmq sdk] [info] all libraries have been written to disk.
npm ERR!   CXX(target) Release/obj.target/rocketmq/src/rocketmq.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info find Python using Python version 3.9.2 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/yunwisdom/Workspace/xdata/xdata-search-service/node_modules/apache-rocketmq/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/yunwisdom/Library/Caches/node-gyp/14.15.4/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/yunwisdom/Library/Caches/node-gyp/14.15.4',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/yunwisdom/Library/Caches/node-gyp/14.15.4/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/yunwisdom/Workspace/xdata/xdata-search-service/node_modules/apache-rocketmq',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! ../src/rocketmq.cpp:42:116: error: too few arguments to function call, single argument 'context' was not specified
npm ERR!     Nan::Set(target, Nan::New("macosDLOpen").ToLocalChecked(), Nan::New<v8::FunctionTemplate>(DLOpen)->GetFunction());
npm ERR!                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
npm ERR! /Users/yunwisdom/Library/Caches/node-gyp/14.15.4/include/node/v8.h:6482:3: note: 'GetFunction' declared here
npm ERR!   V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
npm ERR!   ^
npm ERR! /Users/yunwisdom/Library/Caches/node-gyp/14.15.4/include/node/v8config.h:431:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
npm ERR! #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
npm ERR!                               ^
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/rocketmq/src/rocketmq.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Darwin 20.1.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/yunwisdom/Workspace/xdata/xdata-search-service/node_modules/apache-rocketmq
npm ERR! gyp ERR! node -v v14.15.4
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/yunwisdom/.npm/_logs/2021-03-24T11_50_07_471Z-debug.log

Can not install with npm in docker container

What Happens?

Can not install within docker container

操作系统 Debian 9

image

trace

$ wget https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/linux/1.2.0/UBUNTU/5.5.04/librocketmq.a
--2019-06-03 23:04:24--  https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/linux/1.2.0/UBUNTU/5.5.04/librocketmq.a
Resolving opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com (opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com)... 118.31.219.223
Connecting to opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com (opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com)|118.31.219.223|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-06-03 23:04:24 ERROR 404: Not Found.

操作系统

root@389de4c49908:/# cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

经测试,在Ubuntu 16.04 上可正常安装

> [email protected] install /home/hain/tmp/node_modules/apache-rocketmq                                                                               > node ./script/download_lib.js && node-gyp rebuild

[rocketmq sdk] [info] downloading [https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/linux/1.2.0/UBUNTU/16.04/librocketmq.a]...
[rocketmq sdk] [info] downloaded library [https://opensource-rocketmq-client.oss-cn-hangzhou.aliyuncs.com/cpp-client/linux/1.2.0/UBUNTU/16.04/librocketmq.a].
[rocketmq sdk] [info] all libraries have been written to disk.
make: Entering directory '/home/hain/tmp/node_modules/apache-rocketmq/build'
  CXX(target) Release/obj.target/rocketmq/src/rocketmq.o
  CXX(target) Release/obj.target/rocketmq/src/producer.o
In file included from ../src/producer.cpp:18:0:

This relative module was not found: * ../build/Release

What Happens?

A clear and concise description of what the bug is.

Minimum Showcase (Required)

Provide a minimum code or GitHub repository which can reproduce the issue.

How to Reproduce

Steps to reproduce the behavior:

1.cnpm install
2.This relative module was not found:

Expected behavior

Context

  • Node Version:
  • SDK Version:
  • Platform:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.