List of usage examples for com.rabbitmq.client Consumer handleDelivery
void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException;
basic.deliver
is received for this consumer. From source file:com.streamsets.pipeline.stage.origin.rabbitmq.TestStreamSetsMessageConsumer.java
License:Apache License
@Test public void testConsumerSingleMessage() throws Exception { TransferQueue<RabbitMessage> messages = new LinkedTransferQueue<>(); DataParserFactory parserFactory = new DataParserFactoryBuilder(context, DataParserFormat.JSON) .setCharset(StandardCharsets.UTF_8).setMode(JsonMode.MULTIPLE_OBJECTS).setMaxDataLen(-1).build(); Channel channel = mock(Channel.class); final Consumer consumer = new StreamSetsMessageConsumer(channel, messages); final Envelope envelope = new Envelope(1L, false, EXCHANGE_NAME, QUEUE_NAME); executor.submit(new Runnable() { @Override//from w w w .j av a 2s. c o m public void run() { try { consumer.handleDelivery("consumerTag", envelope, null, TEST_MESSAGE_1.getBytes()); } catch (IOException ignored) { // no op } } }); RabbitMessage message = messages.take(); assertEquals(TEST_MESSAGE_1, new String(message.getBody(), StandardCharsets.UTF_8)); }