|
@@ -13,25 +13,23 @@ class HomeController extends Controller {
|
|
|
async sendmq() {
|
|
|
const { ctx, app } = this;
|
|
|
console.log(msgValue.MsgValues.EXCHANGE_CROP_REG);
|
|
|
- await this.service.rabbitmq.sendQueueMsg(ctx.query.exchange,ctx.query.routekey, new Buffer(JSON.stringify(ctx.query.msg)), (data) =>
|
|
|
- {
|
|
|
- console.log(data);
|
|
|
-
|
|
|
+ await this.service.rabbitmq.sendQueueMsg(ctx.query.exchange, ctx.query.routekey, new Buffer(JSON.stringify(ctx.query.msg)), data => {
|
|
|
+ console.log(data);
|
|
|
+
|
|
|
});
|
|
|
ctx.body = '发送成功';
|
|
|
}
|
|
|
|
|
|
async receivemq() {
|
|
|
const { ctx, app } = this;
|
|
|
- await this.service.rabbitmq.receiveQueueMsg(ctx.query.exchange,ctx.query.routekey,(msg) =>
|
|
|
- {
|
|
|
- console.log(msg);
|
|
|
-
|
|
|
+ await this.service.rabbitmq.receiveQueueMsg(ctx.query.exchange, ctx.query.routekey, msg => {
|
|
|
+ console.log(msg);
|
|
|
+
|
|
|
// 插入待办事项到数据库中。
|
|
|
- await this.service.message.create({producerid: '1', consumerid: '2',type: '1', content: '2222'});
|
|
|
+ this.service.message.create({ producerid: msg.producerid, consumerid: msg.consumerid, type: msg.type, content: msg.content, remark: msg.remark });
|
|
|
|
|
|
});
|
|
|
- ctx.body = "接收成功";
|
|
|
+ ctx.body = '接收成功';
|
|
|
}
|
|
|
}
|
|
|
|