Created
December 27, 2015 16:04
-
-
Save seregasheypak/0adc0fd79e7784483c50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A builder with single spout and bolt. Spout could emit tuples using two streams: | |
// user event with fieldGouping with streamId UserEvent.class.getSimpleName() | |
// game event with streamId GameEvent.class.getSimpleName() | |
builder.setSpout(GenericEventSpout.class.getSimpleName(), new GenericEventSpout(), 2) | |
builder.setBolt(UserContextBolt.class.getSimpleName(), new UserContextBolt(), 2) | |
.addConfigurations(env) | |
.fieldsGrouping(GenericEventSpout.class.getSimpleName(), UserEvent.class.getSimpleName(), new Fields(Const.userId.name())) | |
.allGrouping(GenericEventSpout.class.getSimpleName(), GameEvent.class.getSimpleName()); | |
// Here are stream declarations in Spout: | |
@Override | |
public void declareOutputFields(OutputFieldsDeclarer declarer) { | |
declarer.declareStream(UserEvent.simpleName, new Fields(Const.userId.name(), UserEvent.simpleName)) | |
declarer.declareStream(GameEvent.simpleName, new Fields(GameEvent.simpleName)) | |
} | |
// Here is Bolt: | |
// I see my tuples, it's ok, but all Tupl metadata fields are null | |
@Override | |
public void execute(Tuple input) { | |
LOG.info("input: $input | ${input.messageId}|${input.sourceComponent} ${input.sourceGlobalStreamid} ${input.sourceStreamId} ${input.sourceTask} ") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment