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

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

There is a newer version: 0.26.0
Show newest version
package com.github.libgraviton.workerbase;

import com.github.libgraviton.messaging.QueueConnection;
import com.github.libgraviton.messaging.exception.CannotConnectToQueue;
import com.github.libgraviton.messaging.exception.CannotRegisterConsumer;
import com.github.libgraviton.messaging.strategy.rabbitmq.RabbitMqConnection;

import java.util.Properties;

/**
 * 

QueueManager

* * @author List of contributors {@literal } * @version $Id: $Id * @see http://swisscom.ch */ public class QueueManager { private QueueConnection connection; public QueueManager(Properties properties) { connection = new RabbitMqConnection.Builder() .queueName(properties.getProperty("graviton.workerId")) .routingKey(properties.getProperty("graviton.workerId")) .applyProperties(properties, "queue.") .build(); } /** * Async connection to queue. * * @param worker the worker * * @throws CannotConnectToQueue if connection to queue cannot be established * @throws CannotRegisterConsumer if connection was successfully established, but consumer registration failed */ public void connect(WorkerAbstract worker) throws CannotConnectToQueue, CannotRegisterConsumer { connection.consume(new WorkerConsumer(worker)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy