All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.swisspush.redisques.handler.GetQueueItemsCountHandler Maven / Gradle / Ivy

There is a newer version: 4.1.10
Show newest version
package org.swisspush.redisques.handler;

import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.eventbus.Message;
import io.vertx.core.json.JsonObject;
import io.vertx.redis.client.Response;
import org.slf4j.Logger;

import static org.slf4j.LoggerFactory.getLogger;
import static org.swisspush.redisques.util.RedisquesAPI.ERROR;
import static org.swisspush.redisques.util.RedisquesAPI.OK;
import static org.swisspush.redisques.util.RedisquesAPI.STATUS;
import static org.swisspush.redisques.util.RedisquesAPI.VALUE;

/**
 * Class GetQueueItemsCountHandler.
 *
 * @author Marc-André Weber
 */
public class GetQueueItemsCountHandler implements Handler> {

    private static final Logger log = getLogger(GetQueueItemsCountHandler.class);
    private final Message event;

    public GetQueueItemsCountHandler(Message event) {
        this.event = event;
    }

    @Override
    public void handle(AsyncResult reply) {
        if(reply.succeeded()){
            Long queueItemCount = reply.result().toLong();
            event.reply(new JsonObject().put(STATUS, OK).put(VALUE, queueItemCount));
        } else {
            log.warn("Concealed error", new Exception(reply.cause()));
            event.reply(new JsonObject().put(STATUS, ERROR));
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy