use of com.netflix.conductor.core.events.queue.Message in project conductor by Netflix.
the class TestElasticSearchDAOV5 method addMessage.
@Test
public void addMessage() {
String messageId = "some-message-id";
Message message = new Message();
message.setId(messageId);
message.setPayload("some-payload");
message.setReceipt("some-receipt");
indexDAO.addMessage("some-queue", message);
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
SearchResponse searchResponse = search(LOG_INDEX_PREFIX + "*", "messageId='" + messageId + "'", 0, 10000, "*", MSG_DOC_TYPE);
assertEquals("search results should be length 1", searchResponse.getHits().getTotalHits(), 1);
SearchHit searchHit = searchResponse.getHits().getAt(0);
GetResponse response = elasticSearchClient.prepareGet(searchHit.getIndex(), MSG_DOC_TYPE, searchHit.getId()).get();
assertEquals("indexed message id should match", messageId, response.getSource().get("messageId"));
assertEquals("indexed payload should match", "some-payload", response.getSource().get("payload"));
});
List<Message> messages = indexDAO.getMessages("some-queue");
assertEquals(1, messages.size());
assertEquals(message.getId(), messages.get(0).getId());
assertEquals(message.getPayload(), messages.get(0).getPayload());
}
use of com.netflix.conductor.core.events.queue.Message in project conductor by Netflix.
the class ElasticSearchRestDAOV5 method mapGetMessagesResponse.
private List<Message> mapGetMessagesResponse(SearchResponse response) throws IOException {
SearchHit[] hits = response.getHits().getHits();
TypeFactory factory = TypeFactory.defaultInstance();
MapType type = factory.constructMapType(HashMap.class, String.class, String.class);
List<Message> messages = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
String source = hit.getSourceAsString();
Map<String, String> mapSource = objectMapper.readValue(source, type);
Message msg = new Message(mapSource.get("messageId"), mapSource.get("payload"), null);
messages.add(msg);
}
return messages;
}
use of com.netflix.conductor.core.events.queue.Message in project conductor by Netflix.
the class ElasticSearchDAOV5 method mapGetMessagesResponse.
private List<Message> mapGetMessagesResponse(SearchResponse response) throws IOException {
SearchHit[] hits = response.getHits().getHits();
TypeFactory factory = TypeFactory.defaultInstance();
MapType type = factory.constructMapType(HashMap.class, String.class, String.class);
List<Message> messages = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
String source = hit.getSourceAsString();
Map<String, String> mapSource = objectMapper.readValue(source, type);
Message msg = new Message(mapSource.get("messageId"), mapSource.get("payload"), null);
messages.add(msg);
}
return messages;
}
use of com.netflix.conductor.core.events.queue.Message in project conductor by Netflix.
the class TestElasticSearchDAOV6 method shouldAddMessage.
@Test
public void shouldAddMessage() {
String queue = "queue";
Message message1 = new Message(uuid(), "payload1", null);
Message message2 = new Message(uuid(), "payload2", null);
indexDAO.addMessage(queue, message1);
indexDAO.addMessage(queue, message2);
List<Message> indexedMessages = tryFindResults(() -> indexDAO.getMessages(queue), 2);
assertEquals(2, indexedMessages.size());
assertTrue("Not all messages was indexed", indexedMessages.containsAll(Arrays.asList(message1, message2)));
}
use of com.netflix.conductor.core.events.queue.Message in project conductor by Netflix.
the class ElasticSearchDAOV6 method mapGetMessagesResponse.
private List<Message> mapGetMessagesResponse(SearchResponse response) throws IOException {
SearchHit[] hits = response.getHits().getHits();
TypeFactory factory = TypeFactory.defaultInstance();
MapType type = factory.constructMapType(HashMap.class, String.class, String.class);
List<Message> messages = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
String source = hit.getSourceAsString();
Map<String, String> mapSource = objectMapper.readValue(source, type);
Message msg = new Message(mapSource.get("messageId"), mapSource.get("payload"), null);
messages.add(msg);
}
return messages;
}
Aggregations