-
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 the concept of a QueueIdentifier (plus concrete implementations), pairing the identifier and group fields used in the DeadLetterQueue. - Let enqueue and enqueueIfPresent return a DeadLetterEntry and Optional<DeadLetterEntry. This allows for immediate validation if operations succeeded, as well as additional referral to the entry constructed. - Separate maxSize() into maxQueues() and maxQueueSize(). This allows space for a maximum amount of queues as well as a maximum queue size. This requires the isFull method to take in a QueueIdentifier, to be able to make the correct validation. - Peek should contain the group it is peeking for. Otherwise, results from different (processing) groups may end up in the wrong handlers. Next to that, let peek return an Optional to eliminate null values. - Remove DeadLetterQueue#evaluationSucceeded, in favor of DeadLetterEntry#release. - Remove DeadLetterQueue#evaluationFailed. Instead, the implementations should update the DeadLetterEntry#expiresAt and reinsert the entry, right after performing peek. This safeguards against concurrent retrieval of entries. - Introduce a means to clear out the DeadLetterQueue. - Make all necessary adjustments to committed code (e.g., the DeadLetteringEventHandlerInvoker and InMemoryDeadLetterQueue) to comply with the above description. #2021
- Loading branch information
Showing
13 changed files
with
1,168 additions
and
411 deletions.
There are no files selected for viewing
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
86 changes: 86 additions & 0 deletions
86
...rc/main/java/org/axonframework/eventhandling/deadletter/EventHandlingQueueIdentifier.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,86 @@ | ||
/* | ||
* Copyright (c) 2010-2022. 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.deadletter; | ||
|
||
|
||
import org.axonframework.messaging.deadletter.QueueIdentifier; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Implementation of the {@link QueueIdentifier} dedicated for dead-lettering in event handling components. | ||
* <p> | ||
* This identifier is used to uniquely identify a sequence of events for a specific {@code processingGroup}. The | ||
* sequence identifier is typically the result of a {@link org.axonframework.eventhandling.async.SequencingPolicy#getSequenceIdentifierFor(Object)} | ||
* operation. | ||
* | ||
* @author Steven van Beelen | ||
* @see DeadLetteringEventHandlerInvoker | ||
* @since 4.6.0 | ||
*/ | ||
public class EventHandlingQueueIdentifier implements QueueIdentifier { | ||
|
||
private final Object sequenceIdentifier; | ||
private final String processingGroup; | ||
|
||
/** | ||
* Constructs an event handling specific {@link QueueIdentifier}. | ||
* | ||
* @param sequenceIdentifier The identifier of a sequence of events to enqueue. | ||
* @param processingGroup The processing group that is required to enqueue events. | ||
*/ | ||
public EventHandlingQueueIdentifier(Object sequenceIdentifier, String processingGroup) { | ||
this.sequenceIdentifier = sequenceIdentifier; | ||
this.processingGroup = processingGroup; | ||
} | ||
|
||
@Override | ||
public Object identifier() { | ||
return this.sequenceIdentifier; | ||
} | ||
|
||
@Override | ||
public String group() { | ||
return this.processingGroup; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
EventHandlingQueueIdentifier that = (EventHandlingQueueIdentifier) o; | ||
return Objects.equals(sequenceIdentifier, that.sequenceIdentifier) | ||
&& Objects.equals(processingGroup, that.processingGroup); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(sequenceIdentifier, processingGroup); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "EventHandlingQueueIdentifier{" + | ||
"sequenceIdentifier=" + sequenceIdentifier + | ||
", processingGroup='" + 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
Oops, something went wrong.