use of org.springframework.amqp.rabbit.core.RabbitAdmin in project microservices by pwillhan.
the class RabbitAdminSpringExample method main.
public static void main(String[] args) {
AbstractApplicationContext context = new ClassPathXmlApplicationContext("configuration.xml");
RabbitAdmin admin = context.getBean(RabbitAdmin.class);
}
use of org.springframework.amqp.rabbit.core.RabbitAdmin in project spring-integration by spring-projects.
the class AmqpMessageSourceIntegrationTests method before.
@Before
public void before() {
RabbitAdmin admin = new RabbitAdmin(this.config.connectionFactory());
Queue queue = QueueBuilder.nonDurable(QUEUE_WITH_DLQ).autoDelete().withArgument("x-dead-letter-exchange", "").withArgument("x-dead-letter-routing-key", DLQ).build();
admin.declareQueue(queue);
this.context.start();
}
use of org.springframework.amqp.rabbit.core.RabbitAdmin in project spring-integration by spring-projects.
the class PollableAmqpChannel method onInit.
@Override
protected void onInit() throws Exception {
AmqpTemplate amqpTemplate = getAmqpTemplate();
if (this.queue == null) {
if (getAdmin() == null && amqpTemplate instanceof RabbitTemplate) {
ConnectionFactory connectionFactory = ((RabbitTemplate) amqpTemplate).getConnectionFactory();
setAdmin(new RabbitAdmin(connectionFactory));
setConnectionFactory(connectionFactory);
}
Assert.notNull(getAdmin(), "If no queueName is configured explicitly, an AmqpAdmin instance must be provided, " + "or the AmqpTemplate must be a RabbitTemplate since the Queue needs to be declared.");
this.queue = new Queue(this.channelName);
}
super.onInit();
}
use of org.springframework.amqp.rabbit.core.RabbitAdmin in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testDefaultRabbitConfiguration.
@Test
public void testDefaultRabbitConfiguration() {
load(TestConfiguration.class);
RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
RabbitMessagingTemplate messagingTemplate = this.context.getBean(RabbitMessagingTemplate.class);
CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
RabbitAdmin amqpAdmin = this.context.getBean(RabbitAdmin.class);
assertThat(rabbitTemplate.getConnectionFactory()).isEqualTo(connectionFactory);
assertThat(getMandatory(rabbitTemplate)).isFalse();
assertThat(messagingTemplate.getRabbitTemplate()).isEqualTo(rabbitTemplate);
assertThat(amqpAdmin).isNotNull();
assertThat(connectionFactory.getHost()).isEqualTo("localhost");
assertThat(dfa.getPropertyValue("publisherConfirms")).isEqualTo(false);
assertThat(dfa.getPropertyValue("publisherReturns")).isEqualTo(false);
assertThat(this.context.containsBean("rabbitListenerContainerFactory")).as("Listener container factory should be created by default").isTrue();
}
use of org.springframework.amqp.rabbit.core.RabbitAdmin in project microservices by pwillhan.
the class RabbitAdminExample method main.
public static void main(String[] args) {
CachingConnectionFactory factory = new CachingConnectionFactory("localhost");
RabbitAdmin admin = new RabbitAdmin(factory);
Queue queue = new Queue("test-queue");
admin.declareQueue(queue);
TopicExchange exchange = new TopicExchange("sample-topic-exchange");
admin.declareExchange(exchange);
admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("sample-key"));
factory.destroy();
}
Aggregations