use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class QueueAdapterTestCase method requireThatAccessorsWork.
@Test
public void requireThatAccessorsWork() {
QueueAdapter queue = new QueueAdapter();
assertTrue(queue.isEmpty());
assertEquals(0, queue.size());
Message msg = new MyMessage();
queue.handleMessage(msg);
assertFalse(queue.isEmpty());
assertEquals(1, queue.size());
MyReply reply = new MyReply();
queue.handleReply(reply);
assertFalse(queue.isEmpty());
assertEquals(2, queue.size());
assertSame(msg, queue.dequeue());
assertSame(reply, queue.dequeue());
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class ReceptorTestCase method requireThatAccessorsWork.
@Test
public void requireThatAccessorsWork() {
Receptor receptor = new Receptor();
assertNull(receptor.getMessage(0));
Message msg = new MyMessage();
receptor.handleMessage(msg);
assertSame(msg, receptor.getMessage(0));
Reply reply = new MyReply();
receptor.handleReply(reply);
assertSame(reply, receptor.getReply(0));
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class SimpleFeeder method run.
public SimpleFeeder run() throws Throwable {
VespaXMLFeedReader reader = new VespaXMLFeedReader(in, docTypeMgr);
VespaXMLFeedReader.Operation op = new VespaXMLFeedReader.Operation();
printHeader();
while (failure == null) {
reader.read(op);
if (op.getType() == VespaXMLFeedReader.OperationType.INVALID) {
break;
}
Message msg = newMessage(op);
if (msg == null) {
err.println("ignoring operation; " + op.getType());
// ignore
continue;
}
msg.setContext(System.currentTimeMillis());
msg.setRoute(route);
Error err = session.sendBlocking(msg).getError();
if (err != null) {
throw new IOException(err.toString());
}
++numMessages;
}
while (failure == null && numReplies < numMessages) {
Thread.sleep(100);
}
if (failure != null) {
throw failure;
}
printReport();
return this;
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class SimpleFeederTest method requireThatAsyncFailuresThrowInMainThread.
@Test
public void requireThatAsyncFailuresThrowInMainThread() throws Throwable {
TestDriver driver = new TestDriver(new FeederParams(), "<vespafeed><document documenttype='simple' documentid='doc:scheme:0'/></vespafeed>", new MessageHandler() {
@Override
public void handleMessage(Message msg) {
Reply reply = new EmptyReply();
reply.swapState(msg);
reply.addError(new Error(ErrorCode.APP_FATAL_ERROR + 6, "foo"));
reply.addError(new Error(ErrorCode.APP_FATAL_ERROR + 9, "bar"));
reply.popHandler().handleReply(reply);
}
});
try {
driver.run();
fail();
} catch (IOException e) {
assertMatches("com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage@.+\n" + "\\[UNKNOWN\\(250006\\) @ .+\\]: foo\n" + "\\[UNKNOWN\\(250009\\) @ .+\\]: bar\n", e.getMessage());
}
assertTrue(driver.close());
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class SharedSourceSessionTestCase method requireThatSessionCanSendMessage.
@Test
public void requireThatSessionCanSendMessage() throws InterruptedException {
RemoteServer server = RemoteServer.newInstanceWithInternSlobrok();
SharedSourceSession session = newSourceSession(server.slobrokId(), new SourceSessionParams());
ReplyQueue queue = new ReplyQueue();
Message msg = new SimpleMessage("foo").setRoute(Route.parse(server.connectionSpec()));
msg.pushHandler(queue);
assertTrue(session.sendMessage(msg).isAccepted());
assertNotNull(msg = server.awaitMessage(60, TimeUnit.SECONDS));
server.ackMessage(msg);
assertNotNull(queue.awaitReply(60, TimeUnit.SECONDS));
session.release();
server.close();
}
Aggregations