fix send message type
This commit is contained in:
parent
528d0f0d28
commit
a71199f3ff
@ -6,6 +6,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -35,12 +36,12 @@ public class EventProduceTemplate {
|
||||
this.defaultName = serverName;
|
||||
}
|
||||
|
||||
public void send(String topic, Object message, String tag) {
|
||||
public void send(String topic, Serializable message, String tag) {
|
||||
send(topic, defaultModule, defaultName, message, null, null, null, tag);
|
||||
}
|
||||
|
||||
|
||||
public void send(String topic, Object message) {
|
||||
public void send(String topic, Serializable message) {
|
||||
send(topic, message, null);
|
||||
}
|
||||
|
||||
@ -50,11 +51,11 @@ public class EventProduceTemplate {
|
||||
* @Param: [topic, module, name, message, targetId, targetType]
|
||||
* ` * topic 消息主题
|
||||
*/
|
||||
public void sendShardingMsg(String topic, Object message, String shardingKey) {
|
||||
public void sendShardingMsg(String topic, Serializable message, String shardingKey) {
|
||||
sendShardingMsg(topic, message, shardingKey, null);
|
||||
}
|
||||
|
||||
public void sendShardingMsg(String topic, Object message, String shardingKey, String tag) {
|
||||
public void sendShardingMsg(String topic, Serializable message, String shardingKey, String tag) {
|
||||
sendShardingMsg(topic, message, shardingKey, null, null, tag);
|
||||
}
|
||||
|
||||
@ -66,7 +67,7 @@ public class EventProduceTemplate {
|
||||
* targetId 事件目标对象ID 例如:人员注册,targetId可以设置为user.id,此字段慎传,若shardingKey为空,此时会拿取targetId做为shardingKey,将导致分区不可控
|
||||
* targetType 事件目标类型 例如:user-create ,可用于过滤数据
|
||||
*/
|
||||
public void sendShardingMsg(String topic, Object message, String shardingKey, String targetId, String targetType, String tag) {
|
||||
public void sendShardingMsg(String topic, Serializable message, String shardingKey, String targetId, String targetType, String tag) {
|
||||
send(topic, defaultModule, defaultName, message, shardingKey, targetId, targetType, tag);
|
||||
}
|
||||
|
||||
@ -79,11 +80,11 @@ public class EventProduceTemplate {
|
||||
* targetType 事件目标类型 例如:user-create, user-delete,可用于过滤数据
|
||||
* message 消息内容 ,必填
|
||||
*/
|
||||
public void send(String topic, String module, String name, Object message, String shardingKey, String targetId, String targetType) {
|
||||
public void send(String topic, String module, String name, Serializable message, String shardingKey, String targetId, String targetType) {
|
||||
send(topic, module, name, message, shardingKey, targetId, targetType, null);
|
||||
}
|
||||
|
||||
public void send(String topic, String module, String name, Object message, String shardingKey, String targetId, String targetType, String tag) {
|
||||
public void send(String topic, String module, String name, Serializable message, String shardingKey, String targetId, String targetType, String tag) {
|
||||
//检查参数
|
||||
checkParam(topic, message);
|
||||
Event.EventCode eventCode = new Event.EventCode(module, name);
|
||||
@ -102,7 +103,7 @@ public class EventProduceTemplate {
|
||||
.targetType(targetType).eventCode(eventCode)
|
||||
.eventModule(module)
|
||||
.eventName(name)
|
||||
.operatorId("operatorId").data(message.toString()).build(), content);
|
||||
.operatorId("operatorId").data(message).build(), content);
|
||||
}
|
||||
|
||||
private void checkParam(String topic, Object message) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user