Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Flush message queue instead of discarding them on shutdown#429

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
koenpunt wants to merge1 commit intosegmentio:master
base:master
Choose a base branch
Loading
fromkoenpunt:spring-boot-flush-on-shutdown

Conversation

@koenpunt
Copy link

The defaultdestroyMethod for a Bean is inferred, and uses theclose orshutdown method on the object.

But since theshutdown method of the analytics class stops processing of messages, there's a chance that this would discard messages.

By callingflush it should be able to process the messages before shutdown.

Even better might be to implement the blocking flush for the spring boot starter? (https://github.com/segmentio/analytics-java/blob/master/analytics-sample/src/main/java/sample/BlockingFlush.java)

Let me know what you think!

@koenpunt
Copy link
Author

I looked a bit further, and could it be that the shutdown method also performs a final request with the remaining messages?

if (!messages.isEmpty() && (isOverflow ||isBlockingSignal ||batchSizeLimitReached)) {
Batchbatch =Batch.create(CONTEXT,newArrayList<>(messages),writeKey);
log.print(
VERBOSE,
"Batching %s message(s) into batch %s.",
batch.batch().size(),
batch.sequence());
networkExecutor.submit(
BatchUploadTask.create(AnalyticsClient.this,batch,maximumRetries));

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@koenpunt

[8]ページ先頭

©2009-2025 Movatter.jp