List of usage examples for com.rabbitmq.client Channel exchangeDeclare
Exchange.DeclareOk exchangeDeclare(String exchange, BuiltinExchangeType type, boolean durable) throws IOException;
From source file:util.ExampleSocialMediaStormDeclarator.java
/** * Main RabbitMQ declaration method. Will use RabbitMQ channel reference. * * Rabbit MQ Channel API:/*www .j av a 2 s .c o m*/ * https://www.rabbitmq.com/releases/rabbitmq-java-client/v3.1.5/rabbitmq- * java-client-javadoc-3.1.5/ (search for "Channel") * * @param channel * rabbitmq channel */ @Override public void execute(Channel channel) { try { // Storm any possible arguments that could be passed Map<String, Object> args = new HashMap<>(); /* * Declare the queue * * API: * http://www.rabbitmq.com/releases/rabbitmq-java-client/v1.7.0/ * rabbitmq-java-client-javadoc-1.7.0/com/rabbitmq/client/Channel. * html#queueDeclare(java.lang.String, boolean, boolean, boolean, * boolean, java.util.Map)) * */ channel.queueDeclare(this.strQueueName, true, false, false, args); /* * Declare the exchange * * API: * http://www.rabbitmq.com/releases/rabbitmq-java-client/v1.7.0/ * rabbitmq-java-client-javadoc-1.7.0/com/rabbitmq/client/Channel. * html#exchangeDeclare(java.lang.String, java.lang.String, boolean) */ channel.exchangeDeclare(this.strExchange, this.strExchangeType, this.boolPersistence); /* * Bind the queue * * API: * http://www.rabbitmq.com/releases/rabbitmq-java-client/v1.7.0/ * rabbitmq-java-client-javadoc-1.7.0/com/rabbitmq/client/Channel. * html#queueBind(java.lang.String, java.lang.String, * java.lang.String) */ channel.queueBind(this.strQueueName, this.strExchange, this.strRoutingKey); // Handle Exception and allow to continue } catch (Exception e) { System.err.println("Failed to execute RabbitMQ declarations. Details: " + e.getMessage()); e.printStackTrace(); } }