|
@@ -18,6 +18,7 @@ import org.springframework.messaging.support.MessageBuilder;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: mq 服务实现类
|
|
* @Description: mq 服务实现类
|
|
@@ -45,7 +46,7 @@ public class ProducerServerImpl implements ProducerServer {
|
|
SendResult sendResult = rocketMQTemplate.syncSend(mqDto.getTopic() + ":" + mqDto.getTag(), mqDto);
|
|
SendResult sendResult = rocketMQTemplate.syncSend(mqDto.getTopic() + ":" + mqDto.getTag(), mqDto);
|
|
// 同步消息发送成功会有一个返回值,我们可以用这个返回值进行判断和获取一些信息
|
|
// 同步消息发送成功会有一个返回值,我们可以用这个返回值进行判断和获取一些信息
|
|
log.info("sendResult:{}", JacksonUtil.parseJson(sendResult));
|
|
log.info("sendResult:{}", JacksonUtil.parseJson(sendResult));
|
|
- return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -60,7 +61,7 @@ public class ProducerServerImpl implements ProducerServer {
|
|
SendResult sendResult = rocketMQTemplate.syncSendOrderly(mqDto.getTopic() + ":" + mqDto.getTag(), mqDto, mqDto.getObjId());
|
|
SendResult sendResult = rocketMQTemplate.syncSendOrderly(mqDto.getTopic() + ":" + mqDto.getTag(), mqDto, mqDto.getObjId());
|
|
// 同步顺序消息发送成功会有一个返回值,我们可以用这个返回值进行判断和获取一些信息
|
|
// 同步顺序消息发送成功会有一个返回值,我们可以用这个返回值进行判断和获取一些信息
|
|
log.info("sendResult:{}", JacksonUtil.parseJson(sendResult));
|
|
log.info("sendResult:{}", JacksonUtil.parseJson(sendResult));
|
|
- return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -75,7 +76,7 @@ public class ProducerServerImpl implements ProducerServer {
|
|
Message message = assembleMessage(mqDto);
|
|
Message message = assembleMessage(mqDto);
|
|
org.springframework.messaging.Message messageTran = MessageBuilder.withPayload(message).build();
|
|
org.springframework.messaging.Message messageTran = MessageBuilder.withPayload(message).build();
|
|
rocketMQTemplate.syncSend(mqDto.getTopic() + ":" + mqDto.getTag(), messageTran, SystemConstant.MESSAGE_TIMEOUT, Integer.parseInt(String.valueOf(mqDto.getProperties().get("timeOut"))));
|
|
rocketMQTemplate.syncSend(mqDto.getTopic() + ":" + mqDto.getTag(), messageTran, SystemConstant.MESSAGE_TIMEOUT, Integer.parseInt(String.valueOf(mqDto.getProperties().get("timeOut"))));
|
|
- return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -100,7 +101,7 @@ public class ProducerServerImpl implements ProducerServer {
|
|
throw new BusinessException(throwable.getMessage());
|
|
throw new BusinessException(throwable.getMessage());
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -125,7 +126,7 @@ public class ProducerServerImpl implements ProducerServer {
|
|
throw new BusinessException(throwable.getMessage());
|
|
throw new BusinessException(throwable.getMessage());
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -152,7 +153,7 @@ public class ProducerServerImpl implements ProducerServer {
|
|
throw new BusinessException(throwable.getMessage());
|
|
throw new BusinessException(throwable.getMessage());
|
|
}
|
|
}
|
|
}, SystemConstant.MESSAGE_TIMEOUT, Integer.parseInt(String.valueOf(mqDto.getProperties().get("timeOut"))));
|
|
}, SystemConstant.MESSAGE_TIMEOUT, Integer.parseInt(String.valueOf(mqDto.getProperties().get("timeOut"))));
|
|
- return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -165,7 +166,7 @@ public class ProducerServerImpl implements ProducerServer {
|
|
public Result sendOneWay(MqDto mqDto) {
|
|
public Result sendOneWay(MqDto mqDto) {
|
|
log.info("sendOneWay mqDto:{}", JacksonUtil.parseJson(mqDto));
|
|
log.info("sendOneWay mqDto:{}", JacksonUtil.parseJson(mqDto));
|
|
rocketMQTemplate.sendOneWay(mqDto.getTopic() + ":" + mqDto.getTag(), mqDto);
|
|
rocketMQTemplate.sendOneWay(mqDto.getTopic() + ":" + mqDto.getTag(), mqDto);
|
|
- return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -178,7 +179,7 @@ public class ProducerServerImpl implements ProducerServer {
|
|
public Result sendOneWayOrderly(MqDto mqDto) {
|
|
public Result sendOneWayOrderly(MqDto mqDto) {
|
|
log.info("sendOneWayOrderly mqDto:{}", JacksonUtil.parseJson(mqDto));
|
|
log.info("sendOneWayOrderly mqDto:{}", JacksonUtil.parseJson(mqDto));
|
|
rocketMQTemplate.sendOneWayOrderly(mqDto.getTopic() + ":" + mqDto.getTag(), mqDto, mqDto.getObjId());
|
|
rocketMQTemplate.sendOneWayOrderly(mqDto.getTopic() + ":" + mqDto.getTag(), mqDto, mqDto.getObjId());
|
|
- return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -195,7 +196,7 @@ public class ProducerServerImpl implements ProducerServer {
|
|
//发送事务消息
|
|
//发送事务消息
|
|
TransactionSendResult transactionSendResult = rocketMQTemplate.sendMessageInTransaction(mqDto.getTopic() + ":" + mqDto.getTag(), messageTran, null);
|
|
TransactionSendResult transactionSendResult = rocketMQTemplate.sendMessageInTransaction(mqDto.getTopic() + ":" + mqDto.getTag(), messageTran, null);
|
|
log.info("transactionSendResult:{}", JacksonUtil.parseJson(transactionSendResult));
|
|
log.info("transactionSendResult:{}", JacksonUtil.parseJson(transactionSendResult));
|
|
- return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|