apache-camel RedisSubscriber


public class RedisSubscriber extends RouteBuilder {

    private String redisHost;
    private int redisPort;
    private String redisChannel;

    private Object bean;
    private String method;

    public void setBean(Object bean) {
        this.bean = bean;

    public void setMethod(String method) {
        this.method = method;

    public void configure() throws Exception {
        from(String.format("spring-redis://%s:%s?command=SUBSCRIBE&channels=%s&serializer=#%s", redisHost, redisPort, redisChannel, ManagedCamel.REDIS_SERIALIZER))
                .log(String.format("Consuming with redis in channel: %s, massage body: ${body}", redisChannel))
                .process(exchange -> {
                }).bean(bean, String.format("%s(${body})", method));

The Method 'method' inside the injected bean will handle the massages recived.