com.geneea.celery.brokers.rabbit.RabbitBrokerFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of celery-java Show documentation
Show all versions of celery-java Show documentation
Java library for interfacing with http://celeryproject.org including code for both task submissions and task
execution.
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