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

Saga Caching Enhancements #2531

Merged
merged 19 commits into from Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4bdbb66
Let the CachingIntegrationTestSuite use a TEP
smcvb Dec 23, 2022
cd14ac5
Wrap result of cache retrieval in a new HashSet
smcvb Dec 23, 2022
f67e757
Add more association adjustments
smcvb Dec 27, 2022
871b784
Make WeakReferenceCache#computeIfPresent use EntryListeners
smcvb Dec 27, 2022
51d6d42
Use a Cache.EntryListener to validate instead of the Cache directly
smcvb Dec 27, 2022
990f8c5
Fix wait times
smcvb Dec 27, 2022
06887c0
Add test that triggers the ConcurrentModificationException reliably u…
CodeDrivenMitch Dec 27, 2022
a1c7b6c
Fix concurrency issue on the CachingSagaStore by introducing synchron…
CodeDrivenMitch Dec 27, 2022
d114149
Remove synchronization in the CachingSagaStore and wrap the result of…
CodeDrivenMitch Dec 28, 2022
6d9f030
Fix NPE when using WeakReferenceCache.computeIfPresent due to missing…
CodeDrivenMitch Dec 28, 2022
c94e192
Move concurrency test to CachingSagaStoreTest
CodeDrivenMitch Dec 28, 2022
c6f2a47
Merge pull request #2532 from AxonFramework/enhancement/caching-saga-…
smcvb Dec 28, 2022
ae9dc32
Remove redundant empty lines
smcvb Dec 28, 2022
93c5c81
Adjust indentation and naming of test case for clarity
smcvb Dec 28, 2022
6ee2bf1
Ensure the TEP configuration is set accordingly
smcvb Dec 28, 2022
3aceaf4
Adjust solution in EntryListenerValidator
smcvb Dec 28, 2022
8d272a7
Increase timeouts for resiliency
smcvb Dec 28, 2022
702eb1a
Replace await-call for assertTrue
smcvb Dec 28, 2022
9cf9d45
Adjust indentation
smcvb Dec 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018. Axon Framework
* 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.
Expand All @@ -22,6 +22,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
* Test saga used by the {@link CachingIntegrationTestSuite}.
Expand All @@ -32,17 +33,33 @@ public class CachedSaga {

private String name;
private List<Object> state;
private int numberOfAssociations;
private Random random;
private Integer associationToRemove;

@StartSaga
@SagaEventHandler(associationProperty = "id")
public void on(SagaCreatedEvent event) {
this.name = event.name;
this.state = new ArrayList<>();
this.numberOfAssociations = event.numberOfAssociations;
this.random = new Random();

for (int i = 0; i < numberOfAssociations; i++) {
SagaLifecycle.associateWith(event.id + i, i);
}
}

@SagaEventHandler(associationProperty = "id")
public void on(VeryImportantEvent event) {
state.add(event.stateEntry);
if (associationToRemove == null) {
associationToRemove = random.nextInt(numberOfAssociations);
SagaLifecycle.removeAssociationWith(event.id + associationToRemove, associationToRemove);
} else {
SagaLifecycle.associateWith(event.id + associationToRemove, associationToRemove);
associationToRemove = null;
}
}

@SagaEventHandler(associationProperty = "id")
Expand All @@ -65,10 +82,12 @@ public static class SagaCreatedEvent {

private final String id;
private final String name;
private final int numberOfAssociations;

public SagaCreatedEvent(String id, String name) {
public SagaCreatedEvent(String id, String name, int numberOfAssociations) {
this.id = id;
this.name = name;
this.numberOfAssociations = numberOfAssociations;
}

public String getId() {
Expand Down