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

com.geneea.celery.brokers.rabbit.RabbitBrokerFactory Maven / Gradle / Ivy

Go to download

Java library for interfacing with http://celeryproject.org including code for both task submissions and task execution.

There is a newer version: 1.10.4
Show newest version
package com.geneea.celery.brokers.rabbit;

import com.google.common.collect.ImmutableSet;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.kohsuke.MetaInfServices;
import com.geneea.celery.spi.Broker;
import com.geneea.celery.spi.BrokerFactory;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeoutException;

@MetaInfServices(BrokerFactory.class)
public class RabbitBrokerFactory implements BrokerFactory {
    @Override
    public Set getProtocols() {
        return ImmutableSet.of("amqp", "amqps");
    }

    @Override
    public Broker createBroker(URI uri, ExecutorService executor) throws IOException, TimeoutException {
        ConnectionFactory factory = new ConnectionFactory();
        try {
            factory.setUri(uri);
        } catch (NoSuchAlgorithmException | KeyManagementException | URISyntaxException e) {
            throw new IOException(e);
        }

        Connection connection = factory.newConnection(executor);
        return new RabbitBroker(connection.createChannel());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy