/// <summary> /// Writes a set of events to the queue as a single batch associated with the provided streamId. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="streamGuid"></param> /// <param name="streamNamespace"></param> /// <param name="events"></param> /// <param name="token"></param> /// <param name="requestContext"></param> /// <returns></returns> public async Task QueueMessageBatchAsync <T>(Guid streamGuid, string streamNamespace, IEnumerable <T> events, StreamSequenceToken token, Dictionary <string, object> requestContext) { try { var queueId = streamQueueMapper.GetQueueForStream(streamGuid, streamNamespace); ArraySegment <byte> bodyBytes = serializer.Serialize(new MemoryMessageBody(events.Cast <object>(), requestContext)); var messageData = MemoryMessageData.Create(streamGuid, streamNamespace, bodyBytes); IMemoryStreamQueueGrain queueGrain = GetQueueGrain(queueId); await queueGrain.Enqueue(messageData); } catch (Exception exc) { logger.Error((int)ProviderErrorCode.MemoryStreamProviderBase_QueueMessageBatchAsync, "Exception thrown in MemoryAdapterFactory.QueueMessageBatchAsync.", exc); throw; } }
public async Task QueueMessageBatchAsync <T>(Guid streamGuid, string streamNamespace, IEnumerable <T> events, StreamSequenceToken token, Dictionary <string, object> requestContext) { QueueId queueId; MemoryEventData eventData; try { queueId = streamQueueMapper.GetQueueForStream(streamGuid, streamNamespace); eventData = MemoryBatchContainer.ToMemoryEventData(streamGuid, streamNamespace, events, requestContext); IMemoryStreamQueueGrain queueGrain = GetQueueGrain(queueId); await queueGrain.Enqueue(eventData); } catch (Exception exc) { logger.Error((int)ProviderErrorCode.MemoryStreamProviderBase_QueueMessageBatchAsync, "Exception thrown in MemoryAdapterFactory.QueueMessageBatchAsync.", exc); throw; } }