# shimo-rocketmq

> Aliyun Open Notification Service Client

Latest version **2.3.2** (published 2018-01-05) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install shimo-rocketmq
pnpm add shimo-rocketmq
yarn add shimo-rocketmq
bun add shimo-rocketmq
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.3.2 |
| Published | 2018-01-05 |
| First published | 2017-12-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6.0.0 |
| Dependencies | 19 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 153 |
| Author | gxcsoccer |
| Maintainers | luoyjx |
| Keywords | ons, aliyun, ali-sdk |

## Links

- npm: https://www.npmjs.com/package/shimo-rocketmq
- Repository: https://github.com/ali-sdk/ali-ons
- Homepage: https://github.com/ali-sdk/ali-ons#readme
- Issues: https://github.com/ali-sdk/ali-ons/issues
- npm.io page: https://npm.io/package/shimo-rocketmq

## Dependencies (19)

- [co](https://npm.io/package/co.md) ^4.6.0
- [byte](https://npm.io/package/byte.md) ^1.2.0
- [long](https://npm.io/package/long.md) ^3.2.0
- [JSON2](https://npm.io/package/JSON2.md) ^0.1.0
- [bytes](https://npm.io/package/bytes.md) ^3.0.0
- [chalk](https://npm.io/package/chalk.md) ^2.1.0
- [debug](https://npm.io/package/debug.md) ^3.1.0
- [osenv](https://npm.io/package/osenv.md) ^0.1.4
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [address](https://npm.io/package/address.md) ^1.0.3
- [utility](https://npm.io/package/utility.md) ^1.12.0
- [hashring](https://npm.io/package/hashring.md) ^3.2.0
- [sdk-base](https://npm.io/package/sdk-base.md) ^3.3.0
- [tcp-base](https://npm.io/package/tcp-base.md) ^3.0.0
- [co-gather](https://npm.io/package/co-gather.md) ^0.0.1
- [egg-logger](https://npm.io/package/egg-logger.md) ^1.6.0
- [is-type-of](https://npm.io/package/is-type-of.md) ^1.2.0
- [mz-modules](https://npm.io/package/mz-modules.md) ^2.0.0
- [binary-search-insert](https://npm.io/package/binary-search-insert.md) ^1.0.3

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads
- [@react-md/material-icons](https://npm.io/package/@react-md/material-icons.md) — 1.6K weekly downloads

## Recent versions

- 2.3.2 (latest) — 2018-01-05
- 2.3.1 — 2018-01-05
- 2.3.0 — 2017-12-22
- 2.2.1 — 2017-12-21

## README

shimo-rocketmq
=======

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![David deps][david-image]][david-url]
[![node version][node-image]][node-url]

[npm-image]: https://img.shields.io/npm/v/ali-ons.svg?style=flat-square
[npm-url]: https://npmjs.org/package/ali-ons
[travis-image]: https://img.shields.io/travis/ali-sdk/ali-ons.svg?style=flat-square
[travis-url]: https://travis-ci.org/ali-sdk/ali-ons
[david-image]: https://img.shields.io/david/ali-sdk/ali-ons.svg?style=flat-square
[david-url]: https://david-dm.org/ali-sdk/ali-ons
[node-image]: https://img.shields.io/badge/node.js-%3E=_4.2.3-green.svg?style=flat-square
[node-url]: http://nodejs.org/download/

Aliyun Open Notification Service Client (base on opensource project [RocketMQ](https://github.com/alibaba/RocketMQ/tree/master/rocketmq-client))

Sub module of [ali-sdk](https://github.com/ali-sdk/ali-sdk).

## Install

```bash
npm install shimo-rocketmq --save
```

## Usage

consumer

```js
'use strict';

const httpclient = require('urllib');
const Consumer = require('ali-ons').Consumer;
const consumer = new Consumer({
  httpclient,
  accessKey: 'your-accesskey',
  secretKey: 'your-secretkey',
  consumerGroup: 'your-consumer-group',
  // isBroadcast: true,
});

consumer.subscribe(config.topic, '*', function*(msg) {
  console.log(`receive message, msgId: ${msg.msgId}, body: ${msg.body.toString()}`)
});

consumer.on('error', err => console.log(err));
```

producer

```js
'use strict';

const co = require('co');
const httpclient = require('urllib');
const Producer = require('ali-ons').Producer;
const Message = require('ali-ons').Message;

const producer = new Producer({
  httpclient,
  accessKey: 'your-accesskey',
  secretKey: 'your-secretkey',
  producerGroup: 'your-producer-group',
});

producer.ready(() => {
  console.log('producer ready');
  const msg = new Message('your-topic', // topic
    'TagA', // tag
    'Hello ONS !!! ' // body
  );

  // Might be an order id or other key you want
  const shardingKey = 'your sharding key goes here'

  co(function *() {
    // Send normal message, message will delivery averagely into topic queues
    let sendResult = yield * producer.send(msg);

    // Send sharding message
    // Messages will be delivered into queues which depends on sharding key,
    // that means the messages with same sharding key will always be deliveried
    // into same queue, but you should handle the situation when consumers scaling yourself. 
    sendResult = yield * producer.send(msg, shardingKey);
  });
});
```

Rocketmq

implemention from [yeliex/rocketmq](https://github.com/yeliex/rocketmq)

consumer 

```js
const consumer = new Consumer({
  namesrvAddr: 'localhost:9876', // for rocket mq
  accessKey: 'your-accesskey',  // for aliyun-ons
  secretKey: 'your-secretkey',  // for aliyun-ons
  onsAddr: '',                   // for aliyun-ons
  consumerGroup: 'your-consumer-group',  // for aliyun-ons
  
  isBroadcast: false, // default is false, that mean messages will be pushed to consumer cluster only once.
});
```

producer

```js
const producer = new Producer({
  namesrvAddr: 'localhost:9876', // for rocket mq
  accessKey: 'your-accesskey',   // for aliyun-ons
  secretKey: 'your-secretkey',    // for aliyun-ons
  producerGroup: 'your-producer-group',  // for aliyun-ons
});
```

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/shimo-rocketmq · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
