Commit 0f6d5671 authored by yanzg's avatar yanzg

修改MQ请求尸体,防止出错

parent 8e32744e
......@@ -3,13 +3,13 @@ package com.yanzuoguang.mq.service;
import com.rabbitmq.client.Channel;
import com.yanzuoguang.mq.vo.MessageVo;
import com.yanzuoguang.mq.vo.QueueVo;
import com.yanzuoguang.mq.vo.req.RegisterServerTokenReqVo;
import com.yanzuoguang.mq.vo.req.ServerMessageReqVo;
import com.yanzuoguang.mq.vo.req.ServerQueueReqVo;
import com.yanzuoguang.mq.vo.req.RegisterServerTokenReqVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
/**
* 消息队列服务
......@@ -80,6 +80,16 @@ public interface MqService {
@ApiOperation(value = "建立当前服务器的队列")
String createServerQueue(ServerQueueReqVo req);
/**
* 动态注册消费者回调队列
*
* @param queueName 队列名称
* @param messageListener  消费者
* @return
*/
@ApiOperation(value = "动态注册消费者回调队列")
SimpleMessageListenerContainer setQueueConsumer(String queueName, ChannelAwareMessageListener messageListener);
/**
* 注册当前消费队列的回调
*
......
......@@ -24,6 +24,7 @@ import com.yanzuoguang.util.log.Log;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -184,6 +185,18 @@ public class MqServiceImpl implements MqService, InitializingBean {
return localQueueName;
}
/**
* 动态注册消费者回调队列
*
* @param queueName 队列名称
* @param messageListener  消费者
* @return
*/
@Override
public SimpleMessageListenerContainer setQueueConsumer(String queueName, ChannelAwareMessageListener messageListener) {
return this.mqConsumeDynamic.init(queueName, messageListener);
}
/**
* 注册当前消费队列的回调
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment