use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class MbusRequestHandler method handleRequest.
@Override
public ContentChannel handleRequest(final Request request, final ResponseHandler handler) {
if (!(request instanceof MbusRequest)) {
throw new UnsupportedOperationException("Expected MbusRequest, got " + request.getClass().getName() + ".");
}
final Message msg = ((MbusRequest) request).getMessage();
msg.pushHandler(new RespondingReplyHandler(handler));
handleMessage(msg);
return null;
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class DocumentProcessingHandlerAllMessageTypesTestCase method batchDocumentUpdate.
private void batchDocumentUpdate() throws InterruptedException {
DocumentUpdate doc1 = new DocumentUpdate(getType(), new DocumentId("userdoc:test:12345:multi:1"));
DocumentUpdate doc2 = new DocumentUpdate(getType(), new DocumentId("userdoc:test:12345:multi:2"));
Field testField = getType().getField("blahblah");
doc1.addFieldUpdate(FieldUpdate.createAssign(testField, new StringFieldValue("1 not yet processed")));
doc2.addFieldUpdate(FieldUpdate.createAssign(testField, new StringFieldValue("2 not yet processed")));
BatchDocumentUpdateMessage message = new BatchDocumentUpdateMessage(12345);
message.addUpdate(doc1);
message.addUpdate(doc2);
assertTrue(sendMessage(FOOBAR, message));
Message remote1 = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
assertTrue(remote1 instanceof UpdateDocumentMessage);
remoteServer.ackMessage(remote1);
assertNull(driver.client().awaitReply(100, TimeUnit.MILLISECONDS));
Message remote2 = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
assertTrue(remote2 instanceof UpdateDocumentMessage);
remoteServer.ackMessage(remote2);
Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS);
assertNotNull(reply);
assertFalse(reply.hasErrors());
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class DocumentProcessingHandlerAllMessageTypesTestCase method get.
private void get() throws InterruptedException {
GetDocumentMessage message = new GetDocumentMessage(new DocumentId("doc:this:is:a:test"), "fieldset?");
assertTrue(sendMessage(FOOBAR, message));
Message result = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
assertNotNull(result);
remoteServer.ackMessage(result);
Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS);
assertNotNull(reply);
assertThat(result, instanceOf(GetDocumentMessage.class));
assertFalse(reply.hasErrors());
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class DocumentProcessingHandlerForkTestCase method assertPutMessages.
private void assertPutMessages(DocumentMessage msg, String route, String... expected) throws InterruptedException {
msg.getTrace().setLevel(9);
assertTrue(sendMessage(route, msg));
String[] actual = new String[expected.length];
for (int i = 0; i < expected.length; ++i) {
Message remoteMsg = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
assertTrue(remoteMsg instanceof PutDocumentMessage);
remoteMsg.getTrace().trace(1, "remoteServer.ack(" + expected[i] + ")");
remoteServer.ackMessage(remoteMsg);
actual[i] = ((PutDocumentMessage) remoteMsg).getDocumentPut().getDocument().getId().toString();
}
assertNull(remoteServer.awaitMessage(100, TimeUnit.MILLISECONDS));
Arrays.sort(expected);
Arrays.sort(actual);
assertArrayEquals(expected, actual);
Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS);
assertNotNull(reply);
assertFalse(reply.hasErrors());
String trace = reply.getTrace().toString();
for (String documentId : expected) {
assertTrue("missing trace for document '" + documentId + "'\n" + trace, trace.contains("remoteServer.ack(" + documentId + ")"));
}
if (expected.length == 1) {
assertFalse("unexpected fork in trace for single document\n" + trace, trace.contains("<fork>"));
} else {
assertTrue("missing fork in trace for " + expected.length + " split\n" + trace, trace.contains("<fork>"));
}
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class DocumentProcessingHandlerTransformingMessagesTestCase method sendMessageAndGetResult.
private Routable sendMessageAndGetResult(DocumentMessage message) throws InterruptedException {
assertTrue(sendMessage(FOOBAR, message));
Message result = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
assertNotNull(result);
remoteServer.ackMessage(result);
Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS);
assertNotNull(reply);
assertFalse(reply.hasErrors());
return result;
}
Aggregations