Sometimes, setting up a notification system can be complicated, and for it we can use different options (eg: Websockets, Polling), any of the mentioned examples have different implementations and conceptual problems, such as security in websockets or the overload of traffic in a polling system.
- Use Webflux to make your systems efficient and robust 💪
- Refrain from your notifiers implementations 💆
- Keep the architecture you want for your project and leave the rest to Flux-Notifier 😊
-
1 - Importing dependencies
- Maven:
<dependency> <groupId>io.github.jorgerojasdev</groupId> <artifactId>spring-boot-flux-notifier</artifactId> <version>0.2.1</version> </dependency>
- Gradle:
dependencies { implementation 'io.github.jorgerojasdev:spring-boot-flux-notifier:0.0.1-SNAPSHOT' }
- Maven:
-
2 - Generating a Notifier
This step is really simple, we just have to create an interface that extends Notifier <?>, where ? is the class we want to work on as a notification, Ex:
public interface NotificationExampleService extends Notifier<String> { }
And voilá, we do not need to do anything else, the implementation has all the necessary methods to start working
* Do not implement more methods to the Notifier, it can lead to exceptions
-
3 - Creating Configuration
We must create a configuration that has the annotation EnableFluxNotifiers, this receives as a basePackages parameter the root on which FluxNotifier will search its implementations, Ex:@Configuration @EnableFluxNotifiers(basePackages = "io.github.jorgerojasdev") public class NotificatorExampleConfig { ... }
-
4 - Starting to Notify
And that's all, now you can start subscribing to the notifier and start issuing notifications 😄