org.swisspush.redisques.handler.GetQueueItemsCountHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redisques Show documentation
Show all versions of redisques Show documentation
A highly scalable redis-persistent queuing system for vertx
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