rxjava-scheduler-spring-boot-starter

Spring Boot Netflix RxJava Declarative Schedulers

License

License

Categories

Categories

Spring Boot Container Microservices RxJava Reactive libraries
GroupId

GroupId

io.jmnarloch
ArtifactId

ArtifactId

rxjava-scheduler-spring-boot-starter
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

rxjava-scheduler-spring-boot-starter
Spring Boot Netflix RxJava Declarative Schedulers
Project URL

Project URL

https://github.com/jmnarloch/rxjava-scheduler-spring-boot-starter
Source Code Management

Source Code Management

https://github.com/jmnarloch/rxjava-scheduler-spring-boot-starter.git

Download rxjava-scheduler-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/io.jmnarloch/rxjava-scheduler-spring-boot-starter/ -->
<dependency>
    <groupId>io.jmnarloch</groupId>
    <artifactId>rxjava-scheduler-spring-boot-starter</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.jmnarloch/rxjava-scheduler-spring-boot-starter/
implementation 'io.jmnarloch:rxjava-scheduler-spring-boot-starter:1.0.0'
// https://jarcasting.com/artifacts/io.jmnarloch/rxjava-scheduler-spring-boot-starter/
implementation ("io.jmnarloch:rxjava-scheduler-spring-boot-starter:1.0.0")
'io.jmnarloch:rxjava-scheduler-spring-boot-starter:jar:1.0.0'
<dependency org="io.jmnarloch" name="rxjava-scheduler-spring-boot-starter" rev="1.0.0">
  <artifact name="rxjava-scheduler-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.jmnarloch', module='rxjava-scheduler-spring-boot-starter', version='1.0.0')
)
libraryDependencies += "io.jmnarloch" % "rxjava-scheduler-spring-boot-starter" % "1.0.0"
[io.jmnarloch/rxjava-scheduler-spring-boot-starter "1.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-aop jar 1.3.1.RELEASE
org.springframework.boot : spring-boot-configuration-processor Optional jar 1.3.1.RELEASE
io.reactivex : rxjava jar 1.0.14

test (8)

Group / Artifact Type Version
org.mockito : mockito-all jar 1.10.19
junit : junit jar 4.12
org.powermock : powermock-classloading-xstream jar 1.6.5
org.powermock : powermock-module-junit4 jar 1.6.5
org.springframework.boot : spring-boot-starter-web jar 1.3.1.RELEASE
org.powermock : powermock-api-mockito jar 1.6.5
org.powermock : powermock-module-junit4-rule jar 1.6.5
org.springframework.boot : spring-boot-starter-test jar 1.3.1.RELEASE

Project Modules

There are no modules declared in this project.

Spring Boot Netflix RxJava Declarative Schedulers

A Spring Boot starter for RxJava schedulers integration

Build Status Coverage Status

Setup

Add the Spring Boot starter to your project:

<dependency>
  <groupId>io.jmnarloch</groupId>
  <artifactId>rxjava-scheduler-spring-boot-starter</artifactId>
  <version>1.0.0</version>
</dependency>

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<Invoice> getInvoices() {
            return Observable.just(
                ...
            );
        }

        @SubscribeOnBean("executorScheduler")
        public Observable<Invoice> 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

Versions

Version
1.0.0