Resource injection not configured for Sagas in Axon 3

94 views
Skip to first unread message

Ted Steen

unread,
Sep 26, 2016, 12:16:54 PM9/26/16
to axonfr...@googlegroups.com
Hi, long time no see Axon! :)

It seems like the resource injector is not setup properly in Axon 3.

Using out of the box axon-spring doesn't give me a configured resource injector and trying to wire up the configuration myself using the ModuleConfiguration `SagaConfiguration` does not let me.

I think the only way would be to set up all the components myself.

Wanted to check if this is a known bug/limitation or if perhaps I'm on the wrong track here.

Cheers,
Ted Steen

Allard Buijze

unread,
Sep 26, 2016, 5:40:00 PM9/26/16
to axonfr...@googlegroups.com
Hi Ted,

yeah, it's a known bug. Is already fixed, but nit released yet. Will happen soon...

Cheers,

Allard
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pietro Marrone

unread,
Sep 27, 2016, 8:59:34 AM9/27/16
to Axon Framework Users
Is the bug present for @EventHandler ?
I found it using @EnableAxonAutoConfiguration even with @Order(Ordered.LOWEST_PRECEDENCE)
It seems that axon will instanciate the bean before Spring boot, and than Spring can't inject resources such as JPARepository

Is yes how to workaround it?

Pietro Marrone

unread,
Sep 27, 2016, 9:05:21 AM9/27/16
to Axon Framework Users
I found a Workaround but it is very bad:

  public static void main(final String[] args) {

 
final ApplicationContext ctx = SpringApplication.run(SsppApplication.class, args);

   
final RisorsaEventHandler r = ctx.getBean(RisorsaEventHandler.class);
   
final RisorsaQueryRepository repo = ctx.getBean(RisorsaQueryRepository.class);
    r
.setRisorsaQueryRepository(repo);

Allard Buijze

unread,
Sep 28, 2016, 3:02:18 PM9/28/16
to Axon Framework Users
The issue has been found and fixed. It will be part of the next release.

It had to do with the timing of the Axon components being registered with Axon. It happened too early, preveting these beans from being autowired properly.

Cheers,

Allard
Op di 27 sep. 2016 om 15:05 schreef Pietro Marrone <pietro...@gmail.com>

Kirk Daries

unread,
Oct 4, 2016, 3:03:57 AM10/4/16
to Axon Framework Users
I've hit a similar issue. 

My EventStorageEngine bean is being ignored and keeps defaulting to the InMemoryEventStorage
Any timeline with this release Allard? Or anyway i can access that snapshot?

Allard Buijze

unread,
Oct 5, 2016, 8:47:20 AM10/5/16
to Axon Framework Users
Hi Kirk,

can you share a sample of your configuration? It may be something else in this case.
The next release will be made this week. It will be an M5 or RC1 release, depending on whether we manage to get certain fixes in.

Cheers,

Allard

Kirk Daries

unread,
Oct 5, 2016, 1:15:17 PM10/5/16
to Axon Framework Users
I was tweaking the current AxonBank sample:

I tweaked the following in DistributedCommandBusConfig:



//    @Bean
   
public EventStorageEngine postgresEventStorageEngine(Serializer serializer) {
       
return new PostgresEventStorage(entityManagerProvider(), springTransactionManager(), serializer);
   
}


//    @Bean
//    public EventStorageEngine eventStorageEngine() throws Exception {
//        return new JpaEventStorageEngine(entityManagerProvider(), springTransactionManager());
//    }


   
@Bean
   
public SagaStore<Object> postgresJPASagaStore(Serializer serializer) {
       
return new PostgresJsonSagaStore(serializer, entityManagerProvider());
   
}


   
@Bean
   
public EventStore eventStore(EventStorageEngine eventStorageEngine, Serializer serializer) {
     
return new EmbeddedEventStore(postgresEventStorageEngine(serializer));
   
}

Essentially, when i comment out the last 'eventStore' bean, i kept on getting the InMemoryStorageEngine bean.
I added a Custom postgres event storage engine - using JsonB as the payload. I can pass that code alone if it will help.

Allard Buijze

unread,
Oct 10, 2016, 9:43:34 AM10/10/16
to Axon Framework Users
I cannot reproduce this on my local environment. It seems to work fine.
In you code snippet, there is a comment in front of the @Bean. Is that just a copy past issue, or is that there in your code as well?

Cheers,

Allard
Reply all
Reply to author
Forward
0 new messages