home.js 694 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. class HomeController extends Controller {
  4. async index() {
  5. const { ctx } = this;
  6. ctx.body = 'hi, egg';
  7. }
  8. async sendmq() {
  9. const { ctx } = this;
  10. // const msg = { userid: ctx.body.userid, name: ctx.body.name, createtime: ctx.body.createtime, type: ctx.body.type, content: ctx.body.content, remark: ctx.body.remark };
  11. const ex = 'schedule';
  12. const routekey = '11';
  13. const parm = { durable: true, headers: { userId: '2', type: '1', name: '哈哈' } };
  14. await this.service.rabbitmq.sendQueueMsg(ex, routekey, 'hhhsss', parm);
  15. this.ctx.body = '发送成功';
  16. }
  17. }
  18. module.exports = HomeController;