public static KafkaBatchContainer ToBatchContainer( this ConsumeResult <byte[], byte[]> result, SerializationManager serializationManager, QueueProperties queueProperties ) { var sequence = new EventSequenceTokenV2(result.Offset.Value); if (queueProperties.IsExternal) { var key = Encoding.UTF8.GetString(result.Key); return(new KafkaBatchContainer( StreamProviderUtils.GenerateStreamGuid(key), queueProperties.Namespace, new List <object> { Encoding.UTF8.GetString(result.Value) }, null, isExternalBatch: true, sequence, result.TopicPartitionOffset )); } var batchContainer = serializationManager.DeserializeFromByteArray <KafkaBatchContainer>(result.Value); if (batchContainer.SequenceToken == null) { batchContainer.SequenceToken = sequence; } batchContainer.TopicPartitionOffSet = result.TopicPartitionOffset; return(batchContainer); }
public static KafkaBatchContainer ToBatchContainer( this ConsumeResult <byte[], byte[]> result, SerializationManager serializationManager, KafkaStreamOptions options, string streamNamespace ) { var externalHeader = result.Headers.FirstOrDefault(header => header.Key == options.ExternalMessageIdentifier); var sequence = new EventSequenceTokenV2(result.Offset.Value); if (externalHeader != null) { var isExternal = BitConverter.ToBoolean(externalHeader.GetValueBytes(), 0); if (isExternal) { var key = Encoding.UTF8.GetString(result.Key); return(new KafkaBatchContainer( StreamProviderUtils.GenerateStreamGuid(key), streamNamespace, new List <object> { Encoding.UTF8.GetString(result.Value) }, null, isExternalBatch: true, sequence, result.TopicPartitionOffset )); } } var batchContainer = serializationManager.DeserializeFromByteArray <KafkaBatchContainer>(result.Value); if (batchContainer.SequenceToken == null) { batchContainer.SequenceToken = sequence; } batchContainer.TopicPartitionOffSet = result.TopicPartitionOffset; return(batchContainer); }
public static KafkaBatchContainer ToBatchContainer( this ConsumeResult <byte[], byte[]> result, SerializationContext serializationContext, QueueProperties queueProperties ) { var sequence = new EventSequenceTokenV2(result.Offset.Value); if (queueProperties.IsExternal) { var key = Encoding.UTF8.GetString(result.Message.Key); var message = serializationContext .ExternalStreamDeserializer .Deserialize(queueProperties, queueProperties.ExternalContractType, result.Message.Value); return(new KafkaBatchContainer( StreamProviderUtils.GenerateStreamGuid(key), queueProperties.Namespace, new List <object> { message }, null, sequence, result.TopicPartitionOffset )); } var serializationManager = serializationContext.SerializationManager; var batchContainer = serializationManager.DeserializeFromByteArray <KafkaBatchContainer>(result.Message.Value); batchContainer.SequenceToken ??= sequence; batchContainer.TopicPartitionOffSet = result.TopicPartitionOffset; return(batchContainer); }
public static IAsyncStream <T> GetStream <T>(this IStreamProvider streamProvider, string streamId, string streamNamespace) => streamProvider.GetStream <T>(StreamProviderUtils.GenerateStreamGuid(streamId), streamNamespace);