@Test public void testChannel() throws Exception { AMB amb = AMBBuilder.builder().seed("rabbitmq://localhost:5672").build(); String testValue = UID.randomUID(); final AsyncResultImpl<String> res = new AsyncResultImpl<String>(); amb.connect().get(); Channel channel = amb.channel().name("hello").build(); channel.setCallback( new OnChannel() { public void onchannel(AMB amb, Channel channel, Message message) { res.completed(message.string()); } }); channel.join().get(); channel.send(testValue); // Assert.assertEquals(testValue, res.get()); for (; ; ) Thread.sleep(10); // amb.disconnect(); }
@Test public void testBase() throws Exception { AMB amb = AMBBuilder.builder().seed("rabbitmq://localhost:5672").build(); String testValue = UID.randomUID(); final AsyncResultImpl<String> res = new AsyncResultImpl<String>(); amb.setCallback( new OnMessage() { public void onmessage(AMB amb, Message message) { System.out.println(message.string()); res.completed(message.string()); } }); amb.connect().get(); amb.message().to(amb.id()).data(testValue).send(); Assert.assertEquals(testValue, res.get()); amb.disconnect(); }