-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce and throw EventExecutionException
Construct an exception dedicated for event handling failures. This exception should then carry the required information to store events as dead letters, with things like the sequenceId and processingGroup. The exception should be thrown from the SimpleEventHandlerInvoker, that wraps the original exception of the event handler in it. #2021
- Loading branch information
Showing
3 changed files
with
151 additions
and
7 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
messaging/src/main/java/org/axonframework/eventhandling/EventExecutionException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2010-2021. Axon Framework | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.axonframework.eventhandling; | ||
|
||
import org.axonframework.messaging.HandlerExecutionException; | ||
|
||
/** | ||
* An {@link HandlerExecutionException} implementation indicating an exception occurred during event handling. This | ||
* exception is typically used to wrap checked exceptions thrown from an Event Handler. | ||
* | ||
* @author Steven van Beelen | ||
* @since 4.6.0 | ||
*/ | ||
public class EventExecutionException extends HandlerExecutionException { | ||
|
||
private static final long serialVersionUID = -7002989047107235088L; | ||
|
||
// TODO: 26-11-21 group into ProcessingIdentifier? | ||
private final String sequenceIdentifier; | ||
private final String processingGroup; | ||
|
||
/** | ||
* Constructs an {@link EventExecutionException} using the provided {@code message}, {@code cause}, {@code | ||
* sequenceIdentifier} and {@code processingGroup}. Combines the {@code sequenceIdentifier} and {@code | ||
* processingGroup} with a dash ({@code `-`}) as the {@code details} of this {@link HandlerExecutionException}. | ||
* | ||
* @param message the message describing the exception | ||
* @param cause the cause of the exception | ||
* @param sequenceIdentifier the identifier defining the sequence of the event for which execution failed | ||
* @param processingGroup the name of the processing group the exception occurred in | ||
*/ | ||
public EventExecutionException(String message, | ||
Throwable cause, | ||
String sequenceIdentifier, | ||
String processingGroup) { | ||
super(message, cause, sequenceIdentifier + "-" + processingGroup); | ||
this.sequenceIdentifier = sequenceIdentifier; | ||
this.processingGroup = processingGroup; | ||
} | ||
|
||
/** | ||
* Returns the sequence identifier of the event for which execution failed. | ||
* | ||
* @return the sequence identifier of the event for which execution failed | ||
*/ | ||
public String getSequenceIdentifier() { | ||
return sequenceIdentifier; | ||
} | ||
|
||
/** | ||
* Returns the name of processing group this exception occurred in. | ||
* | ||
* @return the name of processing group this exception occurred in | ||
*/ | ||
public String getProcessingGroup() { | ||
return processingGroup; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters