redis adapter for akyuu
npm install akyuu-adapter-ons --save
Make sure you have a connections section in your configuration file(s). And its adapter should be ons.
- consumerId
- topic
- tags
- accessKey
- secretKey
- options
- producerId
- accessKey
- secretKey
- options
-
notStartConsumer
Not to start consumer, default is false.
-
notStartProducer
Not to start producer, default is false.
// ${project}/config/default/connections.js
"use strict";
module.exports = {
myOnsAdapter: {
consummerId,
producerId,
topic,
tags,
accessKey,
secretKey,
options: {
}
}
}
// ${project}/models/${model}.js
"use strict";
const akyuu = require("akyuu");
const ons = akyuu.config.connection.get('myOnsAdapter');
// consumer
const consumer = ons.consumer;
consumer.on("message", function(msg, ack) {
// DO SOMETHING
});
consumer.listen();
consumer.stop(function() {
// closed
});
// producer
const producer = ons.producer;
producer.send(topic, tags, content, function(err, messageId) {
console.log(arguments);
});
// logger
const logger = ons.logger;
logger.on("data", function(data) {
console.log("[ORIG LOG]", data);
});