Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmnarloch/rxjava-scheduler-spring-boot-starter
Declarative RxJava scheduler definition
https://github.com/jmnarloch/rxjava-scheduler-spring-boot-starter
Last synced: 4 days ago
JSON representation
Declarative RxJava scheduler definition
- Host: GitHub
- URL: https://github.com/jmnarloch/rxjava-scheduler-spring-boot-starter
- Owner: jmnarloch
- License: apache-2.0
- Created: 2016-06-19T20:24:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-06-25T16:57:08.000Z (over 8 years ago)
- Last Synced: 2023-07-04T14:06:54.199Z (over 1 year ago)
- Language: Java
- Size: 83 KB
- Stars: 8
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Boot Netflix RxJava Declarative Schedulers
> A Spring Boot starter for RxJava schedulers integration
[![Build Status](https://travis-ci.org/jmnarloch/rxjava-scheduler-spring-boot-starter.svg?branch=master)](https://travis-ci.org/jmnarloch/rxjava-scheduler-spring-boot-starter)
[![Coverage Status](https://coveralls.io/repos/jmnarloch/rxjava-scheduler-spring-boot-starter/badge.svg?branch=master&service=github)](https://coveralls.io/github/jmnarloch/rxjava-scheduler-spring-boot-starter?branch=master)## Setup
Add the Spring Boot starter to your project:
```xml
io.jmnarloch
rxjava-scheduler-spring-boot-starter
1.0.0```
## Usage
Adds a declarative approach for defining schedulers on the methods RxJava return types: Observable or Single.
* SubscribeOn - subscribes to the RxJava predefined scheduler.
* SubscribeOnBean - subscribes to Scheduler defined as bean within application context.## Example
```
@Configuration
@EnableAspectJAutoProxy
public static class Application {@Bean
public rx.Scheduler executorScheduler() {
return Schedulers.from(
Executors.newSingleThreadExecutor()
);
}
}
```Afterwards you can define that your bean uses the custom scheduler or any of the RxJava predefined scheduler
by annotating your methods. This is going to work as long as the return type is either `Observable` or `Single`.```
@Service
public class InvoiceService {@SubscribeOn(Scheduler.IO)
public Observable getInvoices() {
return Observable.just(
...
);
}@SubscribeOnBean("executorScheduler")
public Observable getUnprocessedInvoices() {
return Observable.just(
...
);
}
}
```Note: You need to enable Spring AOP proxies through `@EnableAspectJAutoProxy` in order to use this extension.
## Properties
The only supported property is `rxjava.schedulers.enabled` which allows to disable this extension.
```
rxjava.schedulers.enabled=true # true by default
```## License
Apache 2.0