Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getty reopen sesion #239

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pkg/remoting/getty/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ func (g *gettyClientHandler) OnMessage(session getty.Session, pkg interface{}) {
}

func (g *gettyClientHandler) OnCron(session getty.Session) {
log.Debug("session{%s} Oncron executing", session.Stat())
g.transferBeatHeart(session, message.HeartBeatMessagePing)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove heartbeat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope to delay the interval between transaction submissions by means of timers in the code. The heartbeat may cause getty to disconnect and reconnect, and the time is uncontrollable.

Copy link
Contributor Author

@kaori-seasons kaori-seasons Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should register the branch transaction in listener#onOpen before the session is reopened

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope to delay the interval between transaction submissions by means of timers in the code. The heartbeat may cause getty to disconnect and reconnect, and the time is uncontrollable.

If the heartbeat is closed, it may cause getty to disconnect and reconnect

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should register the branch transaction in listener#onOpen before the session is reopened

you mean register resource on Open?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I want to call GetResourceManager().branchRegister before registering the resource

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I want to call GetResourceManager().branchRegister before registering the resource

I don't know if I understand it right or not, in my understanding, branch transaction is regietered when a branch rpc is called, so what are you trying to say here is register resource when it's Open ?

}

func (g *gettyClientHandler) transferBeatHeart(session getty.Session, msg message.HeartBeatMessage) {
Expand Down
17 changes: 12 additions & 5 deletions sample/tcc/dubbo/client/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ package main

import (
"context"

"github.com/seata/seata-go/pkg/client"
"time"

"dubbo.apache.org/dubbo-go/v3/common/logger"
"dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/imports"

"github.com/seata/seata-go/pkg/client"
"github.com/seata/seata-go/pkg/common/log"
"github.com/seata/seata-go/pkg/tm"
"github.com/seata/seata-go/sample/tcc/dubbo/client/service"
)
Expand All @@ -43,10 +45,15 @@ func main() {
func test() {
var err error
ctx := tm.Begin(context.Background(), "TestTCCServiceBusiness")
timer := time.NewTimer(15 * time.Second)
defer func() {
resp := tm.CommitOrRollback(ctx, err == nil)
logger.Infof("tx result %v", resp)
<-make(chan struct{})
<-time.After(15 * time.Second)
ok := timer.Stop()
if ok {
resp := tm.CommitOrRollback(ctx, err == nil)
log.Infof("tx result %v", resp)
<-make(chan struct{})
}
}()

resp, err := service.UserProviderInstance.Prepare(ctx, 1)
Expand Down
12 changes: 9 additions & 3 deletions sample/tcc/local/cmd/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main

import (
"context"
"time"

"github.com/seata/seata-go/pkg/client"
"github.com/seata/seata-go/pkg/common/log"
Expand All @@ -30,10 +31,15 @@ func main() {
client.Init()
var err error
ctx := tm.Begin(context.Background(), "TestTCCServiceBusiness")
timer := time.NewTimer(15 * time.Second)
defer func() {
resp := tm.CommitOrRollback(ctx, err == nil)
log.Infof("tx result %v", resp)
<-make(chan struct{})
<-time.After(15 * time.Second)
ok := timer.Stop()
if ok {
resp := tm.CommitOrRollback(ctx, err == nil)
log.Infof("tx result %v", resp)
<-make(chan struct{})
}
}()

tccService := service.NewTestTCCServiceBusinessProxy()
Expand Down