提交 457f1abc 编写于 作者: yizhishang123456's avatar yizhishang123456

将feign移植到tx-client中,保持和demo中的一样的包结构,这样才能扫描到

上级 0a271ede
package com.example.demo.service.impl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author yizhishang
*/
@FeignClient(value = "tx-manager")
public interface MQTxManagerFegin {
/**
* 检查并清理事务数据
* @param groupId 事务组id
* @param taskId 任务id
* @return 事务状态
*/
@GetMapping("/tx/manager/cleanNotifyTransaction")
String cleanNotifyTransactionHttp(@RequestParam(value = "groupId") String groupId, @RequestParam(value = "taskId") String taskId);
/**
* 记录补偿事务数据到tm
*/
@PostMapping("/tx/manager/sendCompensateMsg")
String sendCompensateMsg(@RequestParam("currentTime") long currentTime, @RequestParam("groupId") String groupId,
@RequestParam("model") String model, @RequestParam("address") String address,
@RequestParam("uniqueKey") String uniqueKey,
@RequestParam("className") String className, @RequestParam("methodStr") String methodStr,
@RequestParam("data") String data, @RequestParam("time") long time,
@RequestParam("startError") int startError);
/**
* 获取TM服务地址
* @return txServer
*/
@GetMapping("/tx/manager/getServer")
String getServer();
}
package com.example.demo.service.impl;
import com.codingapi.tx.netty.service.MQTxManagerFeginService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
/**
* @author yizhishang
*/
@Service
public class MQTxManagerFeginServiceImpl implements MQTxManagerFeginService {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private ApplicationContext spring;
@Autowired
private MQTxManagerFegin mqTxManagerFegin;
public void reloadMqTxManagerFegin() {
// if(mqTxManagerFegin == null){
// this.mqTxManagerFegin = spring.getBean(MQTxManagerFegin.class);
// }
}
/**
* 检查并清理事务数据
*
* @param groupId 事务组id
* @param waitTaskId 任务id
* @return 事务状态
*/
@Override
public String cleanNotifyTransactionHttp(String groupId, String waitTaskId) {
reloadMqTxManagerFegin();
logger.info("检查并清理事务数据...groupId:{}, waitTaskId:{}", groupId, waitTaskId);
return mqTxManagerFegin.cleanNotifyTransactionHttp(groupId, waitTaskId);
}
/**
* 记录补偿事务数据到tm
*/
@Override
public String sendCompensateMsg(long currentTime, String groupId, String model, String address, String uniqueKey, String className, String methodStr, String data, long time,int startError) {
reloadMqTxManagerFegin();
logger.info("记录补偿事务数据到tm");
return mqTxManagerFegin.sendCompensateMsg(currentTime, groupId, model, address, uniqueKey, className, methodStr, data, time,startError);
}
/**
* 获取TM服务地址
*
* @return txServer
*/
@Override
public String getServer() {
reloadMqTxManagerFegin();
logger.info("获取TM服务地址");
return mqTxManagerFegin.getServer();
}
}
package com.example.demo.service.impl;
package com.codingapi.tx.netty.service.impl;
import com.example.demo.MQTxManagerFegin;
import com.codingapi.tx.netty.service.MQTxManagerFeginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
......
package com.example.demo.service.impl;
package com.example.demo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册