Hi,
We’re using axon 3.2 in combination with Springboot. I’m running an unit test for a saga with the SagaTestFixture. Now to set the @Autowired annotated attributes of the saga the fixture.registerResource method is used. This works fine.
Question is how do I set the @Value annotated attributes of the Saga?
The problem is that with the SagaTestFixture there is no way access the saga instance, so making the attribute public or adding a setter method won’t help.
Saga:
@Autowired
private transient CorrelationRepository correlationRepository;
Hi Norbert,
The framework gives you the illusion that it uses Spring’s autowire magic to wire in beans, but it actually uses a ResourceInjector
.
This is an Axon Framework interface, which has a SpringResourceInjector
implementation in the axon-spring
module. This specific impl pulls the right beans from the Application Context.
It would be nice if the framework had an ApplicationPropertySpringResourceInjector
, but sadly enough that’s not the case atm.
If you’d like and you’ve got the time for that, a PR for such functionality would be much appreciated.
What you could do as a work around, is wrap your application properties in an @Configuration
annotated Config class.
This will instantiate a Spring Bean, which you can wire in your Saga and through the SagaTestFixture
.
Additionally, as it is a property you’d like to wire, I’d make your maxretries
field transient
as well.
I hope this helps you out Norbert!
Cheers,
Steven