my-rabbitmq-datatransfer

2.0.6 • Public • Published

my-rabbitmq-datatransfer

Installation

This module is designed to be used using either browserify or Node.js it's released in the public npm registry and can be installed using:

npm install my-rabbitmq-datatransfer

Usage

All examples assume that this library is bootstrapped using:

//服务监听(消费者)
var datatransfer = require('my-rabbitmq-datatransfer');
var listen = datatransfer.ListenerApi;
var ctx2 = {
    request: null,
    data: null,
    appid: 'ee4e2e04-3e82-46fd-a6bb-c7549b10c472',
    hospitalcode: 'h0001',
    application: 'app',
    mqOptions: {
        Url: 'amqp://localhost',
        ListenQueue: 'hello1'
    }
};
var ls = new listen(ctx2);
console.log('test2:已开始监听...');

//发送消息(生产者)
var datatransfer = require('my-rabbitmq-datatransfer');

var ctx = {
    request: null,
    data: null,
    msg: 'test-msg',//测试消息
    appid: '1abb8110-4f08-11ea-9ddb-81cfebc4c494',
    hospitalcode: 'h0001',
    application: 'app',
    mqOptions: {
        Url: 'amqp://localhost',
        ListenQueue: 'rp.hello1'
    }

};
//同步发送消息
ctx = datatransfer.SendApi(ctx);
if (ctx.data) {
    console.log('同步请求成功-----------------------');
    console.log(ctx);
    console.log('-----------------------');
}
//异步发送消息
datatransfer.SendApiSync(ctx).then(ctx => {
    console.log('异步请求成功-----------------------');
    console.log(ctx);
    console.log('-----------------------');
});

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i my-rabbitmq-datatransfer

Weekly Downloads

1

Version

2.0.6

License

ISC

Unpacked Size

20 kB

Total Files

15

Last publish

Collaborators

  • zhifengfly