Integrate Actors APIs with Spring
- Dominant language
- Java
- Stars
- 300
- Forks
- 230
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 4
Description
Integrating the Actors API with Spring should follow the same approach as Workflows.
For example:
- Actor registration should happen when the Spring Boot application context load, it shouldn't be done by the user. -> For example: `ActorRuntime.getInstance().registerActor(DemoActorImpl.class);` -> Provide `@EnableDaprActors` annotation.
- All ActorRuntime configuration options should be handled by Spring properties. For example: `ActorRuntime.getInstance().getConfig().setDrainOngoingCallTimeout(Duration.ofSeconds(10));`
- Investigate how to handle annotations `@ActorType` and `@ActorMethod`. Right now actors need to extend AbstractActor, but these are not managed Spring beans, making it difficult to integrate with the ecosystem.
- It would be great to not need to extends `AbstractActor` as this can be automatically done by the framework.
- For state manager -> `super.getActorStateManager().set("lastmessage", something).block();` it would be great to have access by using Spring `@Autowired` in the `Actor` implementation.
The current approach push the user to define an interface annotated with `@ActorType` and `@ActorMethod` and then an implementation with the logic. Next create an implementation class that must extend `AbstractActor`. For a better developer experience, the framework (Spring integration) can collapse this steps into a single annotated implementation class.
This will require some investigation to common use cases and patterns about how users define their actors.
Check also: https://github.com/dapr/java-sdk/tree/master/sdk-tests/src/test/java/io/dapr/it/actors/services/springboot
References:
- https://www.baeldung.com/akka-with-spring#4-retrieving-spring-wired-actors
- https://dev.to/seonwoo960000/bringing-the-actor-model-to-spring-boot-with-pekko-4ffb
Contributor guide
Assessment
This issue has not been assessed yet.