use of com.microsoft.azure.eventhubs.impl.EventDataImpl in project samza by apache.
the class EventHubSystemProducer method createEventData.
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 EventDataImpl(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;
}
Aggregations