@Override public void processElement(ProcessContext c) { String row = c.element().getKey() + " - " + c.element().getValue() + " @ " + c.timestamp().toString(); System.out.println(row); c.output(row); }
@Override public void processElement(ProcessContext c) throws IOException { PubsubMessage pubsubMessage = new PubsubMessage(); pubsubMessage.encodeData(c.element().getBytes()); if (timestampLabelKey != null) { Label timestampLabel = new Label(); timestampLabel.setKey(timestampLabelKey); timestampLabel.setNumValue(c.timestamp().getMillis()); pubsubMessage.setLabel(ImmutableList.of(timestampLabel)); } PublishRequest publishRequest = new PublishRequest(); publishRequest.setTopic(outputTopic).setMessage(pubsubMessage); this.pubsub.topics().publish(publishRequest).execute(); }
@Override public Instant timestamp() { return context.timestamp(); }