![JAR search and dependency download from the Maven repository](/logo.png)
org.swisspush.redisques.handler.GetQueueItemHandler 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 org.swisspush.redisques.exception.RedisQuesExceptionFactory;
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 GetQueueItemHandler.
*
* @author baldim, Marc-André Weber
*/
public class GetQueueItemHandler implements Handler> {
private static final Logger log = getLogger(GetQueueItemHandler.class);
private final Message event;
private final RedisQuesExceptionFactory exceptionFactory;
public GetQueueItemHandler(Message event, RedisQuesExceptionFactory exceptionFactory) {
this.event = event;
this.exceptionFactory = exceptionFactory;
}
@Override
public void handle(AsyncResult reply) {
if(reply.failed()) {
event.reply(exceptionFactory.newReplyException(null, reply.cause()));
} else if (reply.result() != null) {
event.reply(new JsonObject().put(STATUS, OK).put(VALUE, reply.result().toString()));
} else {
event.reply(new JsonObject().put(STATUS, ERROR));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy