Add preStop and postStop methods to perform custom task when exiting app #181

Merged
merged 1 commit into from Oct 30, 2015

Conversation

Projects
None yet
2 participants
@Rizen59
Contributor

Rizen59 commented Oct 30, 2015

I added two conveniants methods in AbstractApplication : preStop and postStop.
As their names indicates, these methods are called before and after the JRebirth stop process (where JIT is closed).

@Rizen59

This comment has been minimized.

Show comment
Hide comment
@Rizen59

Rizen59 Oct 30, 2015

Contributor

We were needed these methods to effectate some additionnal operations, like shutdown properly the database.

Here is the situation we have :

  • each time we want to save datas a wave is send
  • we also have a RE_SAVE callback listened by every component who want do to additionnal things after a performed save
  • when exiting application we perform a save on database, and of course we also want that the RE_SAVE is finish to perform

Adding a postStop allow us "to be sure" that all additionnal wave, like RE_SAVE, have finish to process before shuting down the database.

I say "to be sure" in quote because when I looked to the code I can see that when we close the JRebirth Thread we end the current task queue process. In case of "force close", we completely clear the queue.
The question I am afraid of is : will it happens some cases where the queue can be clear with important wave that were not still processed ? That would cause futur issues.

Contributor

Rizen59 commented Oct 30, 2015

We were needed these methods to effectate some additionnal operations, like shutdown properly the database.

Here is the situation we have :

  • each time we want to save datas a wave is send
  • we also have a RE_SAVE callback listened by every component who want do to additionnal things after a performed save
  • when exiting application we perform a save on database, and of course we also want that the RE_SAVE is finish to perform

Adding a postStop allow us "to be sure" that all additionnal wave, like RE_SAVE, have finish to process before shuting down the database.

I say "to be sure" in quote because when I looked to the code I can see that when we close the JRebirth Thread we end the current task queue process. In case of "force close", we completely clear the queue.
The question I am afraid of is : will it happens some cases where the queue can be clear with important wave that were not still processed ? That would cause futur issues.

@sbordes

This comment has been minimized.

Show comment
Hide comment
@sbordes

sbordes Oct 30, 2015

Member

It depends of the timeout value used: closeRetryDelayFirst closeRetryDelayOther

By default we wait 4s before exit, than 1s if waves are still processed.

But after these 4+1s , all pending tasks are cleared

The idea was to avoid to be blocked by waiting something that will never stop.

So your proposal is good but I have a doubt conerning your data loss after the 5s (delay configurable)

Member

sbordes commented Oct 30, 2015

It depends of the timeout value used: closeRetryDelayFirst closeRetryDelayOther

By default we wait 4s before exit, than 1s if waves are still processed.

But after these 4+1s , all pending tasks are cleared

The idea was to avoid to be blocked by waiting something that will never stop.

So your proposal is good but I have a doubt conerning your data loss after the 5s (delay configurable)

@Rizen59

This comment has been minimized.

Show comment
Hide comment
@Rizen59

Rizen59 Oct 30, 2015

Contributor

Yes, that's what I am afraid of. If some tasks are still present and waiting for processing they will be lost. I am agree that in a normal world 5 secondes would be enough to perform this.
But maybe is there another way to be sure that the callback wave - in our case RE_SAVE - would be performed and finished.

Contributor

Rizen59 commented Oct 30, 2015

Yes, that's what I am afraid of. If some tasks are still present and waiting for processing they will be lost. I am agree that in a normal world 5 secondes would be enough to perform this.
But maybe is there another way to be sure that the callback wave - in our case RE_SAVE - would be performed and finished.

sbordes added a commit that referenced this pull request Oct 30, 2015

Merge pull request #181 from Rizen59/8.x-hotfixes
Add preStop and postStop methods to perform custom task when exiting app

@sbordes sbordes merged commit 5289792 into JRebirth:8.x-hotfixes Oct 30, 2015

@sbordes

This comment has been minimized.

Show comment
Hide comment
@sbordes

sbordes Oct 30, 2015

Member

What you need is a canStop method

Member

sbordes commented Oct 30, 2015

What you need is a canStop method

@sbordes sbordes self-assigned this Sep 9, 2016

@sbordes sbordes added the feature label Jan 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment