use of com.yahoo.bullet.pubsub.PubSubMessage in project bullet-storm by yahoo.
the class QuerySpout method nextTuple.
@Override
public void nextTuple() {
PubSubMessage message = null;
try {
message = subscriber.receive();
} catch (Exception e) {
log.error(e.getMessage());
}
if (message == null) {
Utils.sleep(1);
return;
}
String content = message.getContent();
// If no content, it's a metadata only message. Send it on the METADATA_STREAM.
if (content == null) {
collector.emit(METADATA_STREAM, new Values(message.getId(), message.getMetadata()), message.getId());
} else {
collector.emit(QUERY_STREAM, new Values(message.getId(), message.getContent(), message.getMetadata()), message.getId());
}
}
use of com.yahoo.bullet.pubsub.PubSubMessage in project bullet-storm by yahoo.
the class DRPCQueryResultPubscriberTest method fetch.
private PubSubMessage fetch() {
try {
PubSubMessage message;
do {
message = pubscriber.receive();
Thread.sleep(1);
} while (message == null);
return message;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.yahoo.bullet.pubsub.PubSubMessage in project bullet-storm by yahoo.
the class DRPCResultPublisherTest method testFailing.
@Test(expectedExceptions = PubSubException.class)
public void testFailing() throws Exception {
injectedMockBolt.setFailNumber(1);
Assert.assertEquals(injectedMockBolt.getCount(), 0);
PubSubMessage message = new PubSubMessage("foo", "{}", new Metadata(null, makeReturnInfo("a", "testHost", 80)));
publisher.send(message);
}
use of com.yahoo.bullet.pubsub.PubSubMessage in project bullet-storm by yahoo.
the class DRPCResultPublisherTest method testSending.
@Test
public void testSending() throws Exception {
Assert.assertEquals(injectedMockBolt.getCount(), 0);
PubSubMessage message = new PubSubMessage("foo", "{}", new Metadata(null, makeReturnInfo("a", "testHost", 80)));
publisher.send(message);
Assert.assertEquals(injectedMockBolt.getCount(), 1);
Assert.assertTrue(collector.isAcked());
Assert.assertFalse(collector.isFailed());
// Output is no longer present
Assert.assertFalse(collector.haveOutput());
Assert.assertNull(collector.reset());
message = new PubSubMessage("bar", "{}", new Metadata(null, makeReturnInfo("b", "testHost", 80)));
publisher.send(message);
Assert.assertEquals(injectedMockBolt.getCount(), 2);
Assert.assertTrue(collector.isAcked());
Assert.assertFalse(collector.isFailed());
Assert.assertFalse(collector.haveOutput());
Assert.assertNull(collector.reset());
}
use of com.yahoo.bullet.pubsub.PubSubMessage in project bullet-storm by yahoo.
the class CustomSubscriber method receive.
@Override
public PubSubMessage receive() throws PubSubException {
if (queue.isEmpty()) {
throw new PubSubException("");
}
PubSubMessage message = queue.remove();
received.add(message);
return message;
}
Aggregations