Search in sources :

Example 1 with DRPCTuple

use of com.yahoo.bullet.storm.drpc.utils.DRPCTuple in project bullet-storm by yahoo.

the class DRPCResultPublisher method send.

@Override
public void send(PubSubMessage message) throws PubSubException {
    Metadata metadata = message.getMetadata();
    // Remove the content
    String content = metadata.getContent().toString();
    log.debug("Removing metadata {} for result {}@{}: {}", content, message.getId(), message.getSequence(), message.getContent());
    metadata.setContent(null);
    String serializedMessage = message.asJSON();
    Tuple tuple = new DRPCTuple(new Values(serializedMessage, content));
    // This sends the message through DRPC and not to the collector but it acks or fails accordingly.
    bolt.execute(tuple);
    if (!collector.isAcked()) {
        throw new PubSubException("Message not acked. Unable to send message through DRPC:\n " + serializedMessage);
    }
    // Otherwise, we're good to proceed
    collector.reset();
}
Also used : Metadata(com.yahoo.bullet.pubsub.Metadata) Values(org.apache.storm.tuple.Values) PubSubException(com.yahoo.bullet.pubsub.PubSubException) DRPCTuple(com.yahoo.bullet.storm.drpc.utils.DRPCTuple) DRPCTuple(com.yahoo.bullet.storm.drpc.utils.DRPCTuple) Tuple(org.apache.storm.tuple.Tuple)

Aggregations

Metadata (com.yahoo.bullet.pubsub.Metadata)1 PubSubException (com.yahoo.bullet.pubsub.PubSubException)1 DRPCTuple (com.yahoo.bullet.storm.drpc.utils.DRPCTuple)1 Tuple (org.apache.storm.tuple.Tuple)1 Values (org.apache.storm.tuple.Values)1