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

[AMQ-9593] Add option to clean scheduled messages on startup #1352

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kenliao94
Copy link
Contributor

Working in progress: add an option to delete all scheduled message on startup.

@kenliao94
Copy link
Contributor Author

Hey @mattrpav and @jbonofre I am curious on what you think about the approach here and want to clarify a few things:

  1. I was debating between adding this logic to the job scheduler or the persistence layer (following the approach of deleteAllMessages). However, I noticed that SchedulerBroker doesn't expose their internal scheduler, and it has public methods that deal directly with Message (initially I thought SchedulerBroker is not "message aware" but only "job aware". So I decided to add the logic in SB. What do you think?

  2. I wasn't able to find any other non-message jobs (even job in ByteSequence type is assumed to be unmarshal into Message) scheduled on "JMS" scheduler so I assume that remove all jobs are safe. However, do you know any pitfull for simply remove all jobs?

@kenliao94 kenliao94 force-pushed the clean_scheduled_message branch from 15b6106 to c7c4d1a Compare November 26, 2024 06:37
@kenliao94 kenliao94 changed the title [WIP] Add option to clean scheduled messages on startup Add option to clean scheduled messages on startup Nov 26, 2024
@kenliao94 kenliao94 marked this pull request as ready for review November 26, 2024 06:38
@kenliao94
Copy link
Contributor Author

The PR is now ready for review.

@cshannon
Copy link
Contributor

It might be be better to move the cleanup to the persistence layer just because that's how KahaDB handles clearing messages (as was pointed out). But I don't really care too much either way because the flag on the BrokerService is consistent with the other flag so for users it's still a consistent way to configure it. I'll let @mattrpav and @jbonofre comment to see if they have an opinion.

@kenliao94
Copy link
Contributor Author

@cshannon yeah I was doing that as my first approach. But then I realize I need to somehow expose (by changing the visibility of the field) the name of the scheduler ("JMS") used by SchedulerBroker. I didn't like that approach because it creates some sort of coupling. So I decided to handle it where no visibility needed to change.

@cshannon
Copy link
Contributor

Yeah that's fine, the most important thing is it's consistent for the config (which it is)

Copy link
Contributor

@cshannon cshannon left a comment

Choose a reason for hiding this comment

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

I took a quick look and it generally seems ok but it would be good to have a unit test to verify it works. Something where scheduled messages are added, restart, and verify they are removed etc

@kenliao94
Copy link
Contributor Author

Thanks for the feedback. I will add a unit test.

@kenliao94 kenliao94 changed the title Add option to clean scheduled messages on startup [AMQ-9593] Add option to clean scheduled messages on startup Nov 29, 2024
@@ -184,6 +184,7 @@ public class BrokerService implements Service {
private JmsConnector[] jmsBridgeConnectors; // these are Jms to Jms bridges
// to other jms messaging systems
private boolean deleteAllMessagesOnStartup;
private boolean deleteAllScheduledMessagesOnStartup = false;
Copy link
Contributor

@mattrpav mattrpav Nov 30, 2024

Choose a reason for hiding this comment

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

Scheduled message support is part of the JMS 3.1/2.0 spec. I'm not loving the separate config flag. We don't have a 'deleteAllDurableTopicMessagesOnStartup' flag. It is 'all' messages on startup.

I'm thinking it would be better to have a flag to have the scheduler ignore the deleteAllMessagesOnStartup.

Possible path forward:
v6.x - Scheduler ignores deleteAllMessagesOnStartup by default (to maintain existing behavior)
v7.x - Scheduler honors deleteAllMessagesOnStartup by default

Thoughts?

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 see where you are coming from. Initially I would expect deleteAllMessagesOnStartup will include scheduled messages. I even opened a Jira ticket on it. https://issues.apache.org/jira/projects/AMQ/issues/AMQ-9572?filter=allissues from @jbonofre feedback we should have a separated flag for scheduled messages.

Regarding the proposal in v7.x I think if we have the consensus that deleteAllMessagesOnStartup should include scheduled messages then it makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants