Example usage for com.rabbitmq.client Channel exchangeBind

List of usage examples for com.rabbitmq.client Channel exchangeBind

Introduction

In this page you can find the example usage for com.rabbitmq.client Channel exchangeBind.

Prototype

Exchange.BindOk exchangeBind(String destination, String source, String routingKey) throws IOException;

Source Link

Document

Bind an exchange to an exchange, with no extra arguments.

Usage

From source file:pl.nask.hsn2.bus.rabbitmq.RbtUtils.java

License:Open Source License

/**
 * Creates exchanges and static bindings between them.
 * //from   w  ww  .  j av  a  2s  . c o  m
 * @param connection Connection to Rabbit MQ server.
 * @param exchangeCommonName Common exchange name.
 * @param exchangeServicesName Services exchange name.
 * @param exchangeMonitoringName Monitoring exchange name.
 * @throws BusException Any problem with connection or queue will thrown an exception.
 */
public static void createExchanges(Connection connection, String exchangeCommonName,
        String exchangeServicesName, String exchangeMonitoringName) throws BusException {
    Channel channel = createChannel(connection);
    try {
        channel.exchangeDeclare(exchangeCommonName, "fanout");
        channel.exchangeDeclare(exchangeMonitoringName, "fanout");
        channel.exchangeDeclare(exchangeServicesName, "direct");
        channel.exchangeBind(exchangeMonitoringName, exchangeCommonName, "");
        channel.exchangeBind(exchangeServicesName, exchangeCommonName, "");
    } catch (IOException ex) {
        throw new BusException(ex);
    } finally {
        closeChannel(channel);
    }
}