use of com.yahoo.messagebus.test.SimpleMessage in project vespa by vespa-engine.
the class RoutingContextTestCase method createMessage.
// //////////////////////////////////////////////////////////////////////////////
//
// Utilities
//
// //////////////////////////////////////////////////////////////////////////////
private Message createMessage(String msg) {
Message ret = new SimpleMessage(msg);
ret.getTrace().setLevel(9);
return ret;
}
use of com.yahoo.messagebus.test.SimpleMessage in project vespa by vespa-engine.
the class RoutingTestCase method createMessage.
// //////////////////////////////////////////////////////////////////////////////
//
// Utilities
//
// //////////////////////////////////////////////////////////////////////////////
private static Message createMessage(String msg) {
SimpleMessage ret = new SimpleMessage(msg);
ret.getTrace().setLevel(9);
return ret;
}
use of com.yahoo.messagebus.test.SimpleMessage in project vespa by vespa-engine.
the class LoadBalanceTestCase method testLoadBalance.
public void testLoadBalance() throws ListenFailedException, UnknownHostException {
Slobrok slobrok = new Slobrok();
TestServer src = new TestServer("src", null, slobrok, null);
TestServer dst1 = new TestServer("dst/1", null, slobrok, null);
TestServer dst2 = new TestServer("dst/2", null, slobrok, null);
TestServer dst3 = new TestServer("dst/3", null, slobrok, null);
// set up handlers
final QueueAdapter sq = new QueueAdapter();
SourceSession ss = src.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setThrottlePolicy(null).setReplyHandler(new ReplyHandler() {
@Override
public void handleReply(Reply reply) {
System.out.println(Thread.currentThread().getName() + ": Reply '" + ((SimpleMessage) reply.getMessage()).getValue() + "' received at source.");
sq.handleReply(reply);
}
}));
SimpleDestination h1 = new SimpleDestination(dst1.mb, dst1.net.getIdentity());
SimpleDestination h2 = new SimpleDestination(dst2.mb, dst2.net.getIdentity());
SimpleDestination h3 = new SimpleDestination(dst3.mb, dst3.net.getIdentity());
assertTrue(src.waitSlobrok("dst/*/session", 3));
// send messages
// should be divisible by 3
int msgCnt = 30;
for (int i = 0; i < msgCnt; ++i) {
ss.send(new SimpleMessage("msg" + i), Route.parse("dst/*/session"));
}
// wait for replies
assertTrue(sq.waitSize(msgCnt, 60));
// check handler message distribution
assertEquals(msgCnt / 3, h1.getCount());
assertEquals(msgCnt / 3, h2.getCount());
assertEquals(msgCnt / 3, h3.getCount());
ss.destroy();
h1.session.destroy();
h2.session.destroy();
h3.session.destroy();
dst3.destroy();
dst2.destroy();
dst1.destroy();
src.destroy();
slobrok.stop();
}
use of com.yahoo.messagebus.test.SimpleMessage in project vespa by vespa-engine.
the class RoutableTestCase method testMessageContext.
public void testMessageContext() throws ListenFailedException, UnknownHostException {
Slobrok slobrok = new Slobrok();
TestServer srcServer = new TestServer("src", null, slobrok, null);
TestServer dstServer = new TestServer("dst", null, slobrok, null);
SourceSession srcSession = srcServer.mb.createSourceSession(new Receptor(), new SourceSessionParams().setTimeout(600.0));
DestinationSession dstSession = dstServer.mb.createDestinationSession("session", true, new Receptor());
assertTrue(srcServer.waitSlobrok("dst/session", 1));
Object context = new Object();
Message msg = new SimpleMessage("msg");
msg.setContext(context);
assertTrue(srcSession.send(msg, "dst/session", true).isAccepted());
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertSame(reply.getContext(), context);
srcSession.destroy();
srcServer.destroy();
dstSession.destroy();
dstServer.destroy();
slobrok.stop();
}
use of com.yahoo.messagebus.test.SimpleMessage in project vespa by vespa-engine.
the class RoutableTestCase method testReplyDiscard.
public void testReplyDiscard() {
Receptor handler = new Receptor();
Message msg = new SimpleMessage("foo");
msg.pushHandler(handler);
Reply reply = new SimpleReply("bar");
reply.swapState(msg);
reply.discard();
assertNull(handler.getReply(0));
}
Aggregations