Skip to content

chore(af5): migrate to Axon Framework 5 using axon4to5 skill#26

Open
MateuszNaKodach wants to merge 18 commits into
masterfrom
af-migration-interceptors/ready
Open

chore(af5): migrate to Axon Framework 5 using axon4to5 skill#26
MateuszNaKodach wants to merge 18 commits into
masterfrom
af-migration-interceptors/ready

Conversation

@MateuszNaKodach
Copy link
Copy Markdown
Owner

No description provided.

…essor)

- WhenWeekStartedThenProclaimWeekSymbolProcessor: add @SequencingPolicy(MetadataSequencingPolicy, GAME_ID_KEY)
- WhenWeekSymbolProclaimedThenIncreaseDwellingAvailableCreaturesProcessor: CommandGateway field → CommandDispatcher method param; forEach stream → CompletableFuture.allOf async pattern; add @SequencingPolicy
- WhenCreatureRecruitedThenAddToArmyProcessor: add @SequencingPolicy; rewrite try/catch compensation → exceptionallyCompose
- application.yaml: remove sequencing-policy YAML keys for items 6-8 (moved to @SequencingPolicy annotation); remove orphaned Automation_WhenWeekSymbol*_Processor key
…cessor)

- DwellingReadModelProjector: add @SequencingPolicy(MetadataSequencingPolicy, GAME_ID_KEY)
- GetAllDwellingsQueryHandler: add @SequencingPolicy; dual-role event+query handler
- application.yaml: remove last sequencing-policy YAML key (Read_GetAllDwellings_QueryCache)
- command-gateway items 11-16: commandGateway.send(cmd, metadata) → .resultAs(Void.class) to convert CommandResult→CompletableFuture<Void>; MCP files insert .resultAs before .thenApply chain
- query-gateway item 17: .get() → .get(5, TimeUnit.SECONDS) to add required timeout
- query-gateway item 18 GetDwellingByIdRestApi: already AF5-shaped, no changes
- items 19, 20: GetAllDwellingsQueryHandler, GetDwellingByIdQueryHandler already AF5-shaped (idempotent success)
- item 21 PaidCommandInterceptor: use message param directly, chain.proceed() replaces interceptorChain.proceed(), removed throws Exception
Path A.JPA:
- new EventStoreConfiguration: explicit @bean EventStorageEngine using AggregateBasedJpaEventStorageEngine
- HeroesOfDDDApplication: add @EntityScan for com.dddheroes.heroesofddd, org.axonframework, io.axoniq.framework
Note: AF5 JPA schema change (domain_event_entry -> aggregate_event_entry) required out-of-band before runtime
- PaidCommandInterceptor: remove Repository dep, use CommandDispatcher.forContext(context); chain.proceed(message, context)
- ResourcePoolConfiguration: remove Repository injection for PaidCommandInterceptor
- WhenCreatureRecruitedThenAddToArmyProcessor: fix exceptionallyCompose return type via resultAs(Message.class)
- EventStreamsRestApi: DomainEventMessage->EventMessage (non-generic AF5), EventStore->EventStorageEngine, source(SourcingCondition)
- StreamProcessorsOperations: EventProcessingConfiguration->ApplicationContext, TrackingEventProcessor->StreamingEventProcessor, TokenStore->processingStatus()
- SequencingPolicy import: fix wrong package (core.sequencing.annotation->core.annotation) in 4 files
- pom.xml: remove isolated-* Maven profiles (axon4to5-isolatedtest scaffolding)
Comment on lines +29 to +36
List<EventMessage> readEvents(@PathVariable String streamId) {
var condition = SourcingCondition.conditionFor(EventCriteria.havingTags(streamId));
var stream = eventStorageEngine.source(condition);
var events = new ArrayList<EventMessage>();
while (stream.hasNextAvailable()) {
stream.next().map(MessageStream.Entry::message).ifPresent(events::add);
}
return events;
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Validate that.

public void reset(String processor) {
eventProcessingConfiguration
.eventProcessorByProcessingGroup(processor, TrackingEventProcessor.class)
applicationContext.getBeansOfType(StreamingEventProcessor.class).values().stream()
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: It should use AxonConfiguration


if (command.getPayload() instanceof Command payload) {
public MessageStream<?> interceptOnHandle(CommandMessage message, ProcessingContext context, MessageHandlerInterceptorChain<CommandMessage> chain) {
if (message.payload() instanceof Command payload) {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: validate this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant