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

com.github.libgraviton.workerbase.WorkerConsumer Maven / Gradle / Ivy

There is a newer version: 0.26.0
Show newest version
/**
 * queue consumer - here we have the main logic
 */

package com.github.libgraviton.workerbase;

import com.fasterxml.jackson.jr.ob.JSON;
import com.github.libgraviton.messaging.MessageAcknowledger;
import com.github.libgraviton.messaging.consumer.AcknowledgingConsumer;
import com.github.libgraviton.messaging.exception.CannotConsumeMessage;
import com.github.libgraviton.workerbase.model.QueueEvent;

import java.io.IOException;

/**
 * 

WorkerConsumer class.

* * @author List of contributors {@literal } * @see http://swisscom.ch * @version $Id: $Id */ public class WorkerConsumer implements AcknowledgingConsumer { private WorkerAbstract worker; private MessageAcknowledger acknowledger; /** * constructor * * @param worker worker */ public WorkerConsumer(WorkerAbstract worker) { this.worker = worker; } @Override public void consume(String messageId, String message) throws CannotConsumeMessage { QueueEvent queueEvent; try { queueEvent = JSON.std.beanFrom(QueueEvent.class, message); } catch (IOException e) { throw new CannotConsumeMessage(messageId, message, e); } worker.handleDelivery(queueEvent, messageId, acknowledger); } @Override public void setAcknowledger(MessageAcknowledger acknowledger) { this.acknowledger = acknowledger; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy