use of com.rabbitmq.client.BuiltinExchangeType.TOPIC in project quarkus-quickstarts by quarkusio.
the class QuoteProcessorTest method testProcessor.
@Test
void testProcessor() throws Exception {
String quoteId = UUID.randomUUID().toString();
Channel channel = getChannel();
channel.exchangeDeclare("quotes", TOPIC, true, false, Map.of());
String queue = channel.queueDeclare("quotes", true, false, false, Map.of()).getQueue();
channel.queueBind(queue, "quotes", "#");
AtomicReference<Quote> receivedQuote = new AtomicReference<>(null);
DeliverCallback deliverCallback = (consumerTag, message) -> {
Quote quote = objectMapper.readValue(message.getBody(), Quote.class);
if (!Objects.equals(quote.id, quoteId)) {
return;
}
receivedQuote.set(quote);
};
String consumerTag = channel.basicConsume(queue, true, deliverCallback, tag -> {
});
AMQP.BasicProperties props = new AMQP.BasicProperties.Builder().contentType("text/plain").build();
channel.basicPublish("quote-requests", quoteId, props, quoteId.getBytes(UTF_8));
await().atMost(3, SECONDS).untilAtomic(receivedQuote, notNullValue());
channel.basicCancel(consumerTag);
}
Aggregations