I frequently encounter the need for creating services that concurrently process messages from Redis queues. So I decided to share the knowledge I learned and help others easily bootstrap such a service. I would like a second opinion from code reviews of the library. Please do contribute if you feel like improving it!
Github repo: https://github.com/ikhoury/rstreamer
Sample usage
You create Worker classes that processes incoming messages from a queue.
public class SampleWorker implements Worker {
@Override
public void processSingleItem(String item) {
System.out.println("Got item: " + item);
}
}
You link workers to a task queue using a WorkSubscription:
List<Worker> workers = new ArrayList();
workers.add(new SampleWorker());
WorkSubscription subscription = new WorkSubscription("my:task:queue", workers);
You add your WorkSubscription to a SubscriptionManager that handles the lifecycle of all subscriptions.
subscriptionManager.addSubscription(subscription);
subscriptionManager.activateSubscriptions();
Background threads will spin up, continuously poll tasks, and process them using workers.