Example of using RxJava to poll a remote service
Groovy Kotlin
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
annotations
gradle/wrapper
src
.gitignore
README.adoc
build.gradle
gradlew

README.adoc

rx-message-poll

An example of using RxJava to periodically poll a remote service. Demonstrated:

  • The service returns a JSON array of data which we coalesce into a stream of individual items.

  • Filtering streams.

  • Handling connection errors.

  • De-duplicating data.

  • Unit testing the polling mechanism.

The code is written in Java 8 and the tests with Spock. The example relies on RxJava, Retrofit and the Mockaroo web service.

Running the example

./gradlew run

The example requires an internet connection and an API key for Mockaroo. Create a gradle.properties file that looks like this:

mockaroo.api.key=xxxxxx

Running the tests

./gradlew test

The tests do not require any internet connection or access to Mockaroo.