use of com.netflix.conductor.core.events.queue.Message in project conductor by Netflix.
the class AMQPObservableQueueTest method testPublishMessagesToExchangeAndDefaultConfiguration.
private void testPublishMessagesToExchangeAndDefaultConfiguration(Channel channel, Connection connection, boolean exists, boolean useWorkingChannel) throws IOException, TimeoutException {
final Random random = new Random();
final String name = RandomStringUtils.randomAlphabetic(30), type = "topic", queueName = RandomStringUtils.randomAlphabetic(30), routingKey = RandomStringUtils.randomAlphabetic(30);
final AMQPSettings settings = new AMQPSettings(configuration).fromURI("amqp_exchange:" + name + "?exchangeType=" + type + "&routingKey=" + routingKey + "&deliveryMode=2&durable=true&exclusive=false&autoDelete=true");
assertEquals(true, settings.isDurable());
assertEquals(false, settings.isExclusive());
assertEquals(true, settings.autoDelete());
assertEquals(2, settings.getDeliveryMode());
assertEquals(name, settings.getQueueOrExchangeName());
assertEquals(type, settings.getExchangeType());
assertEquals(routingKey, settings.getRoutingKey());
List<GetResponse> queue = buildQueue(random, batchSize);
channel = mockChannelForExchange(channel, useWorkingChannel, exists, queueName, name, type, routingKey, queue);
AMQPObservableQueue observableQueue = new AMQPObservableQueue(mockConnectionFactory(connection), addresses, true, settings, batchSize, pollTimeMs);
assertArrayEquals(addresses, observableQueue.getAddresses());
assertEquals(AMQPConstants.AMQP_EXCHANGE_TYPE, observableQueue.getType());
assertEquals(AMQPConstants.AMQP_EXCHANGE_TYPE + ":" + name + "?exchangeType=" + type + "&routingKey=" + routingKey + "&deliveryMode=2&durable=true&exclusive=false&autoDelete=true", observableQueue.getName());
assertEquals(name, observableQueue.getURI());
assertEquals(batchSize, observableQueue.getBatchSize());
assertEquals(pollTimeMs, observableQueue.getPollTimeInMS());
assertEquals(queue.size(), observableQueue.size());
List<Message> messages = new LinkedList<>();
Observable.range(0, batchSize).forEach((Integer x) -> messages.add(new Message("" + x, "payload: " + x, null)));
assertEquals(batchSize, messages.size());
observableQueue.publish(messages);
if (useWorkingChannel) {
verify(channel, times(batchSize)).basicPublish(eq(name), eq(routingKey), any(AMQP.BasicProperties.class), any(byte[].class));
}
}
use of com.netflix.conductor.core.events.queue.Message in project conductor by Netflix.
the class AMQPObservableQueueTest method testAck.
@Test
public void testAck() throws IOException, TimeoutException {
// Mock channel and connection
Channel channel = mockBaseChannel();
Connection connection = mockGoodConnection(channel);
final Random random = new Random();
final String name = RandomStringUtils.randomAlphabetic(30), type = "topic", routingKey = RandomStringUtils.randomAlphabetic(30);
final AMQPSettings settings = new AMQPSettings(configuration).fromURI("amqp_exchange:" + name + "?exchangeType=" + type + "&routingKey=" + routingKey);
AMQPObservableQueue observableQueue = new AMQPObservableQueue(mockConnectionFactory(connection), addresses, true, settings, batchSize, pollTimeMs);
List<Message> messages = new LinkedList<>();
Message msg = new Message();
msg.setId("0e3eef8f-ebb1-4244-9665-759ab5bdf433");
msg.setPayload("Payload");
msg.setReceipt("1");
messages.add(msg);
List<String> deliveredTags = observableQueue.ack(messages);
assertNotNull(deliveredTags);
}
Aggregations