本文整理汇总了Java中org.apache.samza.system.OutgoingMessageEnvelope.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java OutgoingMessageEnvelope.getKey方法的具体用法?Java OutgoingMessageEnvelope.getKey怎么用?Java OutgoingMessageEnvelope.getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.samza.system.OutgoingMessageEnvelope
的用法示例。
在下文中一共展示了OutgoingMessageEnvelope.getKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEventData
import org.apache.samza.system.OutgoingMessageEnvelope; //导入方法依赖的package包/类
protected EventData createEventData(String streamId, OutgoingMessageEnvelope envelope) {
Optional<Interceptor> interceptor = Optional.ofNullable(interceptors.getOrDefault(streamId, null));
byte[] eventValue = (byte[]) envelope.getMessage();
if (interceptor.isPresent()) {
eventValue = interceptor.get().intercept(eventValue);
}
EventData eventData = new EventData(eventValue);
eventData.getProperties().put(PRODUCE_TIMESTAMP, Long.toString(System.currentTimeMillis()));
if (config.getSendKeyInEventProperties(systemName)) {
String keyValue = "";
if (envelope.getKey() != null) {
keyValue = (envelope.getKey() instanceof byte[]) ? new String((byte[]) envelope.getKey())
: envelope.getKey().toString();
}
eventData.getProperties().put(KEY, keyValue);
}
return eventData;
}
示例2: send
import org.apache.samza.system.OutgoingMessageEnvelope; //导入方法依赖的package包/类
@Override
public void send(String source, OutgoingMessageEnvelope envelope) {
String msg = String.format("OutputStream:%s Key:%s Value:%s", envelope.getSystemStream(), envelope.getKey(),
new String((byte[]) envelope.getMessage()));
LOG.info(msg);
if (envelope.getKey() != null) {
System.out.println(String.format("Key:%s Value:%s", envelope.getKey(),
new String((byte[]) envelope.getMessage())));
} else {
System.out.println(new String((byte[]) envelope.getMessage()));
}
}
示例3: getId
import org.apache.samza.system.OutgoingMessageEnvelope; //导入方法依赖的package包/类
protected Optional<String> getId(OutgoingMessageEnvelope envelope) {
Object id = envelope.getKey();
if (id == null) {
return Optional.absent();
}
return Optional.of(id.toString());
}
示例4: getEnvelopePartitionId
import org.apache.samza.system.OutgoingMessageEnvelope; //导入方法依赖的package包/类
protected Object getEnvelopePartitionId(OutgoingMessageEnvelope envelope) {
return envelope.getPartitionKey() == null ? envelope.getKey() : envelope.getPartitionKey();
}