/**
* Maybe declare the exchange.
*/
protected void maybeDeclareExchange() {
RabbitAdmin admin = new RabbitAdmin(this.connectionFactory);
if (this.declareExchange) {
Exchange x;
if ("topic".equals(this.exchangeType)) {
x = new TopicExchange(this.exchangeName, this.durable, this.autoDelete);
}
else if ("direct".equals(this.exchangeType)) {
x = new DirectExchange(this.exchangeName, this.durable, this.autoDelete);
}
else if ("fanout".equals(this.exchangeType)) {
x = new FanoutExchange(this.exchangeName, this.durable, this.autoDelete);
}
else if ("headers".equals(this.exchangeType)) {
x = new HeadersExchange(this.exchangeType, this.durable, this.autoDelete);
}
else {
x = new TopicExchange(this.exchangeName, this.durable, this.autoDelete);
}
admin.declareExchange(x);
}
}