use of org.springframework.amqp.core.Declarables in project tutorials by jhkim105.
the class AmqpConfig method fanoutBindings.
@Bean
public Declarables fanoutBindings() {
Queue fanoutQueue1 = new Queue(FANOUT_QUEUE_A, false);
Queue fanoutQueue2 = new Queue(FANOUT_QUEUE_B, false);
FanoutExchange fanoutExchange = new FanoutExchange(FANOUT_EXCHANGE);
return new Declarables(fanoutQueue1, fanoutQueue2, fanoutExchange, BindingBuilder.bind(fanoutQueue1).to(fanoutExchange), BindingBuilder.bind(fanoutQueue2).to(fanoutExchange));
}
use of org.springframework.amqp.core.Declarables in project tutorials by jhkim105.
the class AmqpConfig method topicBindings.
@Bean
public Declarables topicBindings() {
Queue topicQueue1 = new Queue(TOPIC_QUEUE_A, false);
Queue topicQueue2 = new Queue(TOPIC_QUEUE_B, false);
TopicExchange topicExchange = new TopicExchange(TOPIC_EXCHANGE);
return new Declarables(topicQueue1, topicQueue2, topicExchange, BindingBuilder.bind(topicQueue1).to(topicExchange).with("*.important.*"), BindingBuilder.bind(topicQueue2).to(topicExchange).with("#.error"));
}
use of org.springframework.amqp.core.Declarables in project spring-amqp by spring-projects.
the class RabbitAdminTests method testMultiEntities.
@Test
@LogLevels(classes = RabbitAdmin.class, level = "DEBUG")
public void testMultiEntities() {
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
RabbitTemplate template = ctx.getBean(RabbitTemplate.class);
template.convertAndSend("e1", "k1", "foo");
template.convertAndSend("e2", "k2", "bar");
template.convertAndSend("e3", "k3", "baz");
template.convertAndSend("e4", "k4", "qux");
assertThat(template.receiveAndConvert("q1")).isEqualTo("foo");
assertThat(template.receiveAndConvert("q2")).isEqualTo("bar");
assertThat(template.receiveAndConvert("q3")).isEqualTo("baz");
assertThat(template.receiveAndConvert("q4")).isEqualTo("qux");
RabbitAdmin admin = ctx.getBean(RabbitAdmin.class);
admin.deleteQueue("q1");
admin.deleteQueue("q2");
admin.deleteQueue("q3");
admin.deleteQueue("q4");
admin.deleteExchange("e1");
admin.deleteExchange("e2");
admin.deleteExchange("e3");
admin.deleteExchange("e4");
assertThat(admin.getQueueProperties(ctx.getBean(Config.class).prototypeQueueName)).isNull();
Declarables mixedDeclarables = ctx.getBean("ds", Declarables.class);
assertThat(mixedDeclarables.getDeclarablesByType(Queue.class)).hasSize(1).extracting(Queue::getName).contains("q4");
assertThat(mixedDeclarables.getDeclarablesByType(Exchange.class)).hasSize(1).extracting(Exchange::getName).contains("e4");
assertThat(mixedDeclarables.getDeclarablesByType(Binding.class)).hasSize(1).extracting(Binding::getDestination).contains("q4");
ctx.close();
}
Aggregations