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/04/10 05:24:50 UTC
[GitHub] [servicecomb-pack] twistycs opened a new issue #650: globalTxId is
null.
twistycs opened a new issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650
This is Microservice and spring boot All.
Service A call Post Method to Service B , C , D by Async Task.
Put @SagaStart Above @PostMapping On controller Service A
Service B Put @Compensable on method that Controller B call this method
Stop service C for Service B to call Compensable to cancel. It calls cancel but globalTx Id is null.
I put this dependency to Service A and B
<dependency>
<groupId>org.apache.servicecomb.pack</groupId>
<artifactId>omega-spring-starter</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb.pack</groupId>
<artifactId>omega-transport-resttemplate</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb.pack</groupId>
<artifactId>omega-transport-feign</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb.pack</groupId>
<artifactId>omega-context</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb.pack</groupId>
<artifactId>omega-transaction</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb.pack</groupId>
<artifactId>omega-spring-tx</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb.pack</groupId>
<artifactId>omega-transport-dubbo</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb.pack</groupId>
<artifactId>omega-transport-servicecomb</artifactId>
<version>0.5.0</version>
</dependency>
==========================================================
java.lang.NullPointerException: null
at org.apache.servicecomb.pack.contract.grpc.GrpcTxEvent$Builder.setGlobalTxId(GrpcTxEvent.java:999) ~[pack-contract-grpc-0.5.0.jar:0.5.0]
at org.apache.servicecomb.pack.omega.connector.grpc.saga.GrpcSagaClientMessageSender.convertEvent(GrpcSagaClientMessageSender.java:101) ~[omega-connector-grpc-0.5.0.jar:0.5.0]
at org.apache.servicecomb.pack.omega.connector.grpc.saga.GrpcSagaClientMessageSender.send(GrpcSagaClientMessageSender.java:90)
~[omega-connector-grpc-0.5.0.jar:0.5.0]
at org.apache.servicecomb.pack.omega.connector.grpc.saga.SagaLoadBalanceSender$1.apply(SagaLoadBalanceSender.java:45) ~[omega-connector-grpc-0.5.0.jar:0.5.0]
at org.apache.servicecomb.pack.omega.connector.grpc.saga.SagaLoadBalanceSender$1.apply(SagaLoadBalanceSender.java:42) ~[omega-connector-grpc-0.5.0.jar:0.5.0]
at org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceSenderAdapter.doGrpcSend(LoadBalanceSenderAdapter.java:54)
~[omega-connector-grpc-0.5.0.jar:0.5.0]
=========================================================
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] twistycs commented on issue #650: globalTxId is
null.
Posted by GitBox <gi...@apache.org>.
twistycs commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-611965292
Service A Async call B C D and then wait for response B,C,D and then end process .
It's not support with async task?
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] coolbeevip commented on issue #650: globalTxId
is null.
Posted by GitBox <gi...@apache.org>.
coolbeevip commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-613787697
Change the log level of Service A to DEBUG, you can see the detailed information of interceptors
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] twistycs commented on issue #650: globalTxId is
null.
Posted by GitBox <gi...@apache.org>.
twistycs commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-612724272
This is Service A Call B, C and D:
@SagaStart
@PostMapping("/contract")
public ResponseEntity<?> serviceA() {
try {
CompletableFuture<Response> insertServiceB= serviceB.insertServiceB();
CompletableFuture<Response> insertServiceC= serviceC.insertServiceC();
CompletableFuture<Response> insertServiceD= serviceD.insertServiceD();
CompletableFuture.allOf(insertServiceB,insertServiceC,insertServiceD).join();
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Can not created .");
}
return ResponseEntity.status(HttpStatus.CREATED)
}
============================================================
Service B :
@PostMapping()
public ResponseEntity<?> insertServiceB() {
try {
response = serviceB.insertServiceB(customer);
} catch (final Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Can not insert.");
}
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}
Method Service B :
@Compensable(compensationMethod = "cancel")
public Response insertServiceB(Customer customer) {
Response resp = new Response();
try {
insertServiceBRepository.save(customer);
} catch (Exception e) {
e.printStackTrace();
}
return resp;
}
void cancel(Customer customer){
System.out.println("CANCEL CUSTOMER !!!!!!!!!!!!!!!!!!!!!");
}
=======================================================
And Stop Service C
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] twistycs commented on issue #650: globalTxId is
null.
Posted by GitBox <gi...@apache.org>.
twistycs commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-612815631
@EnableOmega ??
i put this but the type EnableOmega is deprecated.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] WillemJiang commented on issue #650: globalTxId
is null.
Posted by GitBox <gi...@apache.org>.
WillemJiang commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-612870481
It should be fine. Please compare your code with the demo code that I showed to you.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] twistycs commented on issue #650: globalTxId is
null.
Posted by GitBox <gi...@apache.org>.
twistycs commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-612798507
yes i try to service A call only Service B with sync task not async but globalTxId is null too.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] WillemJiang commented on issue #650: globalTxId
is null.
Posted by GitBox <gi...@apache.org>.
WillemJiang commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-612070812
Could you show the code which you use @SagaStart and @Componsible?
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] WillemJiang commented on issue #650: globalTxId
is null.
Posted by GitBox <gi...@apache.org>.
WillemJiang commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-612795269
> CompletableFuture<Response> insertServiceB= serviceB.insertServiceB();
> CompletableFuture<Response> insertServiceC= serviceC.insertServiceC();
> CompletableFuture<Response> insertServiceD= serviceD.insertServiceD();
> CompletableFuture.allOf(insertServiceB,insertServiceC,insertServiceD).join();
You are using the async invocations here and the calling thread is quite different for each invocation. As Pack uses thread local to store the GID, it makes sense that GID is null, if the calling thread is changed. Can you try to call the service one by one?
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] WillemJiang commented on issue #650: globalTxId
is null.
Posted by GitBox <gi...@apache.org>.
WillemJiang commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-612810057
How did you inject the Omega to ServiceA?
GID could be null, if the Omega is not started in a right way.
As I cannot check your code here, could you go through the demo code [here](https://github.com/apache/servicecomb-pack/tree/master/demo/saga-spring-demo)
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] twistycs commented on issue #650: globalTxId is
null.
Posted by GitBox <gi...@apache.org>.
twistycs commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-613219582
In demo what is version of omega-spring-starter ?
i use omega-spring-starter-0.5.0 but anotation @EnableOmega can not use, its deprecated.
I'm not sure if @EnableOmega cant use then GID be null.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] WillemJiang edited a comment on issue #650:
globalTxId is null.
Posted by GitBox <gi...@apache.org>.
WillemJiang edited a comment on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-612810057
How did you inject the Omega to ServiceA?
GID could be null, if the Omega is not started in a right way.
As I cannot check your code here, could you go through the demo code [here](https://github.com/apache/servicecomb-pack/tree/master/demo/saga-spring-demo)?
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] WillemJiang commented on issue #650: globalTxId
is null.
Posted by GitBox <gi...@apache.org>.
WillemJiang commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-611956437
How do you invoke the Async service?
If the GlobalTxId is passed the next service call , you will get the NPE error.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] twistycs edited a comment on issue #650:
globalTxId is null.
Posted by GitBox <gi...@apache.org>.
twistycs edited a comment on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-612724272
This is Service A Call B, C and D:
```
@SagaStart
@PostMapping("/contract")
public ResponseEntity<?> serviceA() {
try {
CompletableFuture<Response> insertServiceB= serviceB.insertServiceB();
CompletableFuture<Response> insertServiceC= serviceC.insertServiceC();
CompletableFuture<Response> insertServiceD= serviceD.insertServiceD();
CompletableFuture.allOf(insertServiceB,insertServiceC,insertServiceD).join();
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Can not created .");
}
return ResponseEntity.status(HttpStatus.CREATED)
}
```
============================================================
Service B :
```
@PostMapping()
public ResponseEntity<?> insertServiceB() {
try {
response = serviceB.insertServiceB(customer);
} catch (final Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Can not insert.");
}
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}
```
Method Service B :
```
@Compensable(compensationMethod = "cancel")
public Response insertServiceB(Customer customer) {
Response resp = new Response();
try {
insertServiceBRepository.save(customer);
} catch (Exception e) {
e.printStackTrace();
}
return resp;
}
void cancel(Customer customer){
System.out.println("CANCEL CUSTOMER !!!!!!!!!!!!!!!!!!!!!");
}
```
=======================================================
And Stop Service C
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [servicecomb-pack] coolbeevip commented on issue #650: globalTxId
is null.
Posted by GitBox <gi...@apache.org>.
coolbeevip commented on issue #650: globalTxId is null.
URL: https://github.com/apache/servicecomb-pack/issues/650#issuecomment-613756067
> In demo what is version of omega-spring-starter ?
>
> i use omega-spring-starter-0.5.0 but anotation @EnableOmega can not use, its deprecated.
>
> I'm not sure if @EnableOmega cant use then GID be null.
@EnableOmega is deprecated and is enabled by default, I think it has nothing to do with GID null.
We have implemented various request interceptors [1] to implicitly pass GlD and other parameters, I think the interceptor does not work for some reason. Are you using feign to call serviceB?
[1]https://github.com/apache/servicecomb-pack/tree/master/omega/omega-transport
----------------------------------------------------------------
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
With regards,
Apache Git Services