spinach - A scalable Java Disque client
Spinach is a scalable thread-safe Disque client providing both synchronous and asynchronous APIs. Multiple threads may share one connection if they do not use blocking commands. Spinach is based on lettuce 4. Multiple connections are efficiently managed by the excellent netty NIO framework.
- Requires Java 8
- synchronous, asynchronous and reactive APIs
- SSL and Unix Domain Socket connections
- Codecs (for UTF8/bit/JSON etc. representation of your data)
See the Wiki for more docs.
Binaries and dependency information for Maven, Ivy, Gradle and others can be found at http://search.maven.org.
Example for Maven:
<dependency> <groupId>biz.paluch.redis</groupId> <artifactId>spinach</artifactId> <version>x.y.z</version> </dependency>
All versions: Maven Central
Snapshots: Sonatype OSS Repository
DisqueClient client = DisqueClient.create(DisqueURI.create("host", 7711)); DisqueConnection<String, String> connection = client.connect().sync(); DisqueCommands<String, String> sync = connection.sync(); String jobId = sync.addjob("queue", "body", 1, TimeUnit.MINUTES); Job<String, String> job = sync.getjob("queue"); connection.ackjob(job.getId());
Each Disque command is implemented by one or more methods with names identical to the lowercase Disque command name. Complex commands with multiple modifiers that change the result type include the CamelCased modifier as part of the command name.
Disque connections are designed to be long-lived, and if the connection is lost will reconnect until close() is called. Pending commands that have not timed out will be (re)sent after successful reconnection.
All connections inherit a default timeout from their DisqueClient and and will throw a DisqueException when non-blocking commands fail to return a result before the timeout expires. The timeout defaults to 60 seconds and may be changed in the DisqueClient or for each individual connection.
DisqueConnection<String, String> connection = client.connect(); DisqueAsyncCommands<String, String> async = connection.async(); RedisFuture<String> jobId1 = async.addjob("queue", "body1", 1, SECONDS); RedisFuture<String> jobId2 = async.addjob("queue", "body2", 1, SECONDS); async.awaitAll(jobId1, jobId2) == true jobId1.get() == "D-...a1" jobId2.get() == "D-...a1"
Spinach is built with Apache Maven. The tests require multiple running Disque instances for different test cases which
are configured using a
- Run the build:
- Start Disque (manually):
- Stop Disque (manually):
Github is for social coding: if you want to write code, I encourage contributions through pull requests from forks of this repository. Create Github tickets for bugs and new features and comment on the ones that you are interested in and take a look into CONTRIBUTING.md