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

org.swisspush.redisques.handler.AddQueueItemHandler 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 org.swisspush.redisques.exception.RedisQuesExceptionFactory;

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

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

    private static final Logger log = getLogger(AddQueueItemHandler.class);
    private final Message event;
    private final RedisQuesExceptionFactory exceptionFactory;

    public AddQueueItemHandler(Message event, RedisQuesExceptionFactory exceptionFactory) {
        this.event = event;
        this.exceptionFactory = exceptionFactory;
    }

    @Override
    public void handle(AsyncResult reply) {
        if(reply.succeeded()){
            event.reply(new JsonObject().put(STATUS, OK));
        } else {
            event.reply(exceptionFactory.newReplyException(null, reply.cause()));
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy