|
|
|
@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.context.annotation.Profile; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.aliyun.openservices.ons.api.Message; |
|
|
|
import com.aliyun.openservices.ons.api.ONSFactory; |
|
|
|
import com.aliyun.openservices.ons.api.Producer; |
|
|
|
@@ -68,6 +69,7 @@ public class AliyunRocketMqMessageProducer implements MqBaseProducer { |
|
|
|
producer = ONSFactory.createProducer(properties); |
|
|
|
// 在发送消息前,必须调用 start 方法来启动 Producer,只需调用一次即可 |
|
|
|
producer.start(); |
|
|
|
log.info("aliyunrocketmq producer info :"+JSON.toJSONString(producer)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -75,8 +77,6 @@ public class AliyunRocketMqMessageProducer implements MqBaseProducer { |
|
|
|
if (producer.isClosed()) { |
|
|
|
producer.start(); |
|
|
|
} |
|
|
|
|
|
|
|
log.info("aliyunrocketmq producer info :"+JsonUtil.obj2Json(producer)); |
|
|
|
//循环发送消息 |
|
|
|
Message msg = new Message( // |
|
|
|
// Message 所属的 Topic |
|
|
|
|