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

Add error handler for transactional event #34146

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

Conversation

hyh1016
Copy link

@hyh1016 hyh1016 commented Dec 24, 2024

Exceptions propagated from the transactional event listener are handled by TransactionSynchronizationUtils and are not rethrown.
However, the lack of a configurable error handler for these exceptions makes it difficult to customize exception handling during transactional event processing.
To address this, I added an abstract error handler that can be defined as follows:

@Component
public abstract class TransactionalEventErrorHandlerImpl extends TransactionalEventErrorHandler {

	// can inject other beans

	@Override
	public void handle(ApplicationEvent event, @Nullable Throwable ex) {
		// custom logic
	}

}

@pivotal-cla
Copy link

@hyh1016 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@hyh1016 Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 24, 2024
@rstoyanchev rstoyanchev added in: core Issues in core modules (aop, beans, core, context, expression) in: data Issues in data modules (jdbc, orm, oxm, tx) and removed in: core Issues in core modules (aop, beans, core, context, expression) labels Feb 3, 2025
@snicoll
Copy link
Member

snicoll commented Feb 5, 2025

@hyh1016 thanks for the suggestion but we can't consider this PR until you add some unit tests that demonstrates what this is meant to fix. Can you please amend your proposal with them?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Feb 5, 2025
@hyh1016
Copy link
Author

hyh1016 commented Feb 16, 2025

@snicoll Okay, thanks for the feedback. I added unit tests to demonstrate how the code I added works.
Also, while writing the unit tests, I found an issue in the existing logic, so I updated the original PR and pushed the changes again.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants