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

feat: let consumeRun throw to let message broker handle failures #91

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

TheMaskedTurtle
Copy link
Contributor

@TheMaskedTurtle TheMaskedTurtle commented Dec 11, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce?
Change behavior of computation consumer to let it throw so that message broker can handle failures

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

@TheMaskedTurtle TheMaskedTurtle force-pushed the feat/rabbit-error-handling branch from ed6c931 to dfa0f28 Compare December 12, 2024 09:34
* @author Joris Mancini <joris.mancini_externe at rte-france.com>
*/
public class ComputationException extends RuntimeException {
public ComputationException(String message, Throwable cause) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably better to add the constructor without cause right now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

isCanceled = future.cancel(true); // cancel computation in progress
if (isCanceled) {
if (future == null) {
cleanResultsAndPublishCancel(cancelContext.resultUuid(), cancelContext.receiver());
Copy link
Collaborator

@jonenst jonenst Dec 16, 2024

Choose a reason for hiding this comment

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

this will be run on all but one server who is doing the computation ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it looks like it's already the case after this method returns...?

Copy link
Collaborator

Choose a reason for hiding this comment

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

before we did publishCancelFail but now we do cleanResults and publishStop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

cleanResultsAndPublishCancel(cancelContext.resultUuid(), cancelContext.receiver());
} else {
boolean isCanceled = future.cancel(true); // cancel computation in progress
if (future.isDone() || isCanceled) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure about adding this clean when the computation is done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Signed-off-by: Joris Mancini <[email protected]>
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (CancellationException e) {
LOGGER.info("Computation was interrupted");
Copy link
Collaborator

@jonenst jonenst Dec 17, 2024

Choose a reason for hiding this comment

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

Better to add context (resultUuid) to this log just like above it ?

Signed-off-by: Joris Mancini <[email protected]>
Copy link

sonarcloud bot commented Dec 17, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
60.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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.

2 participants