-
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.
Adjust the DeadLetterQueue on several perspectives, like: - Replace 'add' for 'enqueue' - Enqueue Message instances instead of DeadLetter instances - Rename sequenceId to identifier to be more generic - Add group name to allow uniqueness among e.g. processors or aggregates - Rename DeadLetter to DeadLetterEntry - Add expiresAt field to DeadLetterEntry, as a handle to trigger evaluation - Remove poll() method from DeadLetterQueue - Return a single DeadLetterEntry from peek() - Add failed/succeeded methods to the DeadLetterQueue to mark a letter as successfully or failed evaluation. Failing should allow updating the cause - Introduce notion of the queue being full - Update test suite according to the above #2021
- Loading branch information
Showing
5 changed files
with
421 additions
and
166 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
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
30 changes: 30 additions & 0 deletions
30
.../src/main/java/org/axonframework/messaging/deadletter/DeadLetterQueueFilledException.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,30 @@ | ||
/* | ||
* 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.messaging.deadletter; | ||
|
||
import org.axonframework.common.AxonException; | ||
|
||
/** | ||
* @author Steven van Beelen | ||
* @since 4.6.0 | ||
*/ | ||
public class DeadLetterQueueFilledException extends AxonException { | ||
|
||
public DeadLetterQueueFilledException(String message) { | ||
super(message); | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
messaging/src/test/java/org/axonframework/messaging/deadletter/DeadLetterEntryTest.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,96 @@ | ||
/* | ||
* 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.messaging.deadletter; | ||
|
||
import org.axonframework.messaging.Message; | ||
import org.junit.jupiter.api.*; | ||
|
||
import java.time.Instant; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class DeadLetterEntryTest { | ||
|
||
@Test | ||
void testCompareReturnsValueLowerThanZeroIfFirstLetterOccurredBeforeSecond() { | ||
Instant firstLetterTimestamp = Instant.ofEpochMilli(3000); | ||
Instant secondLetterTimestamp = Instant.ofEpochMilli(6000); | ||
TestDeadLetterEntry firstLetter = new TestDeadLetterEntry(firstLetterTimestamp); | ||
TestDeadLetterEntry secondLetter = new TestDeadLetterEntry(secondLetterTimestamp); | ||
|
||
assertTrue(DeadLetterEntry.compare(firstLetter, secondLetter) < 0); | ||
} | ||
|
||
@Test | ||
void testCompareReturnsValueHigherThanZeroIfFirstLetterOccurredAfterSecond() { | ||
Instant firstLetterTimestamp = Instant.ofEpochMilli(6000); | ||
Instant secondLetterTimestamp = Instant.ofEpochMilli(3000); | ||
TestDeadLetterEntry firstLetter = new TestDeadLetterEntry(firstLetterTimestamp); | ||
TestDeadLetterEntry secondLetter = new TestDeadLetterEntry(secondLetterTimestamp); | ||
|
||
assertTrue(DeadLetterEntry.compare(firstLetter, secondLetter) > 0); | ||
} | ||
|
||
@Test | ||
void testCompareReturnsZeroIfFirstAndSecondLetterOccurredAtTheSameTime() { | ||
Instant firstLetterTimestamp = Instant.ofEpochMilli(3000); | ||
Instant secondLetterTimestamp = Instant.ofEpochMilli(3000); | ||
TestDeadLetterEntry firstLetter = new TestDeadLetterEntry(firstLetterTimestamp); | ||
TestDeadLetterEntry secondLetter = new TestDeadLetterEntry(secondLetterTimestamp); | ||
|
||
assertEquals(0, DeadLetterEntry.compare(firstLetter, secondLetter)); | ||
} | ||
|
||
private static class TestDeadLetterEntry implements DeadLetterEntry<Message<?>> { | ||
|
||
private final Instant deadLettered; | ||
|
||
private TestDeadLetterEntry(Instant deadLettered) { | ||
this.deadLettered = deadLettered; | ||
} | ||
|
||
@Override | ||
public String identifier() { | ||
return "some-identifier"; | ||
} | ||
|
||
@Override | ||
public String group() { | ||
return "some-group"; | ||
} | ||
|
||
@Override | ||
public Message<?> message() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Throwable cause() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Instant expiresAt() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Instant deadLettered() { | ||
return deadLettered; | ||
} | ||
} | ||
} |
Oops, something went wrong.