Exemplo n.º 1
0
        public IBatchContainer GetBatchContainer(ref CachedMessage cachedMessage)
        {
            //Deserialize payload
            int readOffset = 0;
            ArraySegment <byte> payload = SegmentBuilder.ReadNextBytes(cachedMessage.Segment, ref readOffset);
            MemoryMessageData   message = MemoryMessageData.Create(cachedMessage.StreamGuid, cachedMessage.StreamNamespace, new ArraySegment <byte>(payload.ToArray()));

            return(new MemoryBatchContainer <TSerializer>(message, this.serializer));
        }
Exemplo n.º 2
0
 /// <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;
     }
 }