You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/05/11 10:41:11 UTC
[GitHub] [servicecomb-pack] gjguanjie opened a new issue #658: saga使用问题,不一定是bug
gjguanjie opened a new issue #658:
URL: https://github.com/apache/servicecomb-pack/issues/658
使用https://hub.docker.com/r/coolbeevip/servicecomb-pack中 docker-compose.yaml 方式启动标准镜像只包含 Alpha 服务。 含状态机了。
客户端中引入,使用restTemplate方式
<dependency>
<groupId>org.apache.servicecomb.pack</groupId>
<artifactId>omega-spring-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicecomb.pack</groupId>
<artifactId>omega-transport-resttemplate</artifactId>
</dependency>
测试如下 代码如下:
服务1:
@RestController
@RequestMapping("/saga")
public class SagaController {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@Resource
private RestTemplate template;
@GetMapping("/start")
@SagaStart
public void start() {
LOGGER.error("调服务");
template.postForObject("http://localhost:9001/service/test",null,String.class);
}
}
服务2:
@RestController
@RequestMapping("service")
public class SagaServiceController {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().getClass());
@Resource
private SagaService sagaService;
@PostMapping("test")
public void test(){
sagaService.test();
}
}
@Service
public class SagaService {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().getClass());
@Compensable(compensationMethod = "cancel")
public void test() {
int aa = 1;
LOGGER.error("测试方法");
int bb = 1/0;
}
public void cancel() {
LOGGER.error("Cancel方法");
}
}
当调用服务1接口http://localhost:9000/saga/start时,遇到服务2中报错,原则上,会调用cancel方法,但没有执行。
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-pack] gjguanjie commented on issue #658: saga使用问题,不一定是bug
Posted by GitBox <gi...@apache.org>.
gjguanjie commented on issue #658:
URL: https://github.com/apache/servicecomb-pack/issues/658#issuecomment-626669151
从原理上讲,应该与服务多与少没有关系吧?从架构上,或服务A作为入口,调用服务B时,B服务出错,服务B方法中使用@Compensable(compensationMethod = "cancel"),那应该就会执行Alpha反回调cancel.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-pack] gjguanjie edited a comment on issue #658: saga使用问题,不一定是bug
Posted by GitBox <gi...@apache.org>.
gjguanjie edited a comment on issue #658:
URL: https://github.com/apache/servicecomb-pack/issues/658#issuecomment-626671111
https://servicecomb.apache.org/cn/docs/distributed-transaction-of-services-1 这文章上,也没有讲,服务多与少问题吧,
另我试了,服务A先调用服务B、再调用服务C,仅服务C出问题,会现调用cancel方法。如果服务B出问题。这时服务B不会调用cancel方法。因为状态那一块原码我没有再看。。。。
那么,我就不会知道,调用服务深度要多少(或服务多少)才能使用。
原理上讲,即使是服务A调用服务B这样简单的服务,至少也分布式事务。
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-pack] gjguanjie removed a comment on issue #658: saga使用问题,不一定是bug
Posted by GitBox <gi...@apache.org>.
gjguanjie removed a comment on issue #658:
URL: https://github.com/apache/servicecomb-pack/issues/658#issuecomment-626669151
从原理上讲,应该与服务多与少没有关系吧?从架构上,或服务A作为入口,调用服务B时,B服务出错,服务B方法中使用@Compensable(compensationMethod = "cancel"),那应该就会执行Alpha反回调cancel.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-pack] gjguanjie commented on issue #658: saga使用问题,不一定是bug
Posted by GitBox <gi...@apache.org>.
gjguanjie commented on issue #658:
URL: https://github.com/apache/servicecomb-pack/issues/658#issuecomment-626671111
https://servicecomb.apache.org/cn/docs/distributed-transaction-of-services-1 这文章上,也没有讲,服务多与少问题吧,
另我试了,服务A调用服务B和服务C,仅服务C出问题,还是不出会现调用cancel方法。
那么,我就不会知道,调用服务深度要多少(或服务多少)才能使用。
原理上讲,即使是服务A调用服务B这样简单的服务,至少也分布式事务。
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-pack] gjguanjie edited a comment on issue #658: saga使用问题,不一定是bug
Posted by GitBox <gi...@apache.org>.
gjguanjie edited a comment on issue #658:
URL: https://github.com/apache/servicecomb-pack/issues/658#issuecomment-626671111
https://servicecomb.apache.org/cn/docs/distributed-transaction-of-services-1 这文章上,也没有讲,服务多与少问题吧,
另我试了,服务A调用服务B和服务C,仅服务C出问题,会现调用cancel方法。
那么,我就不会知道,调用服务深度要多少(或服务多少)才能使用。
原理上讲,即使是服务A调用服务B这样简单的服务,至少也分布式事务。
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-pack] WillemJiang commented on issue #658: saga使用问题,不一定是bug
Posted by GitBox <gi...@apache.org>.
WillemJiang commented on issue #658:
URL: https://github.com/apache/servicecomb-pack/issues/658#issuecomment-626657433
你这边调用的服务还是比较少,如果只是一个服务调用失败的,Saga, TCC都不会调用这个服务的恢复方法。 建议你可以看一下 https://servicecomb.apache.org/cn/docs/distributed-transaction-of-services-1 这篇文章。
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org