Search in sources :

Example 1 with EventDataImpl

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;
}
Also used : EventDataImpl(com.microsoft.azure.eventhubs.impl.EventDataImpl) Interceptor(org.apache.samza.system.eventhub.Interceptor) EventData(com.microsoft.azure.eventhubs.EventData)

Aggregations

EventData (com.microsoft.azure.eventhubs.EventData)1 EventDataImpl (com.microsoft.azure.eventhubs.impl.EventDataImpl)1 Interceptor (org.apache.samza.system.eventhub.Interceptor)1