|
@ -12,7 +12,8 @@ module.exports = async function factory(app, opts) { |
|
|
console.log('111111 ready 666666666666') |
|
|
console.log('111111 ready 666666666666') |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
let consumer = new Kafka.ConsumerGroup(Object.assign({}, { fromOffset: 'latest' }, { kafkaHost: opts.kafka.rootURL }), ['anxinyun_alarm']) |
|
|
let groupId = 'group' + Math.random() |
|
|
|
|
|
let consumer = new Kafka.ConsumerGroup(Object.assign({}, { groupId, fromOffset: 'latest' }, { kafkaHost: opts.kafka.rootURL }), ['anxinyun_alarm']) |
|
|
consumer.on('message', async function (message) { |
|
|
consumer.on('message', async function (message) { |
|
|
let msg = JSON.parse(message.value) |
|
|
let msg = JSON.parse(message.value) |
|
|
console.log('kafka consumer----------接收到消息'); |
|
|
console.log('kafka consumer----------接收到消息'); |
|
@ -80,8 +81,10 @@ module.exports = async function factory(app, opts) { |
|
|
try { |
|
|
try { |
|
|
if (!structsAche.dataList.length || moment() > moment(structsAche.expireTime)) { |
|
|
if (!structsAche.dataList.length || moment() > moment(structsAche.expireTime)) { |
|
|
let structList = await getAxyStructs(); |
|
|
let structList = await getAxyStructs(); |
|
|
structsAche.dataList = structList; |
|
|
if (structList && structList.length) { |
|
|
structsAche.expireTime = moment().add(10, 'minute').format('YYYY-MM-DD HH:mm:ss'); |
|
|
structsAche.dataList = structList; |
|
|
|
|
|
structsAche.expireTime = moment().add(10, 'minute').format('YYYY-MM-DD HH:mm:ss'); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return structsAche; |
|
|
return structsAche; |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|