grpc / grpc-dotnet

gRPC for .NET
Apache License 2.0
4.2k stars 769 forks source link

gRpc distributed transaction #310

Closed VenkateshSrini closed 5 years ago

VenkateshSrini commented 5 years ago

Hi All,

I see many thoughts that say that gRpc could be a replacement for WCF services. With cloud computing in place I like the idea. But we started migrating on project, we are struck in place where we will have to handle transaction. In gRpc is there a way we can create a transaction context and attach it to each service call, and then, when we will have to rollback, we just say commit or roll back from transaction context ? I'm asking two phase commit with client being the transaction coordinator. That would remove any broker or middleware for this purpose

JamesNK commented 5 years ago

Hi

I'm not familiar with WCF's transaction support. Are you using this? https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/servicemodel-transaction-attributes

gRPC uses HTTP/2 for the underlying transport. If a call is still in progress then you could cancel a call, which would send a cancellation request to the server that you could listen to. However in gRPC there isn't an equivalent for sending a commit message.

VenkateshSrini commented 5 years ago

So what is the guidance for migrating such distributed transaction (WS atomic transaction) with gRpc. I'm talking something like https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-create-a-transactional-service. You can about WS-AT here

JamesNK commented 5 years ago

I don't know of an equivalent to WS atomic transaction in gRPC.

davidfowl commented 5 years ago

There's nothing built in (and likely will never be). Using sagas might help here https://microservices.io/patterns/data/saga.html

jtattermusch commented 5 years ago

None of the gRPC implementations has transaction support. Transactions are a higher level concept than gRPC. Also, gRPC is meant to be general-purpose RPC framework and transactions are a pretty specific concept. You could probably implement a library that uses gRPC and adds transaction support on top of it, but it's probably never going to be part of gRPC itself.

VenkateshSrini commented 5 years ago

Hi, Thanks for all your comments. Is there any such library that you can point me to. I want that to be in .NET core preferably .NET core 2.1 or later

gattytto commented 4 years ago

@VenkateshSrini check this out https://github.com/googleapis/googleapis/blob/master/google/ads/googleads/v4/services/google_ads_service.proto#L207