/// <summary> /// Create a MessageWrapper instance from an EventMessage based on message size and strategy /// </summary> /// <param name="eventMessage">Message to wrap</param> /// <param name="veryLargeMessageStrategy">Stategy for very large message</param> /// <returns> /// Wrapper for the message /// </returns> public MessageWrapper CreateMessageFromEvent(EventMessage eventMessage, VeryLargeMessageStrategy veryLargeMessageStrategy) { MessageWrapper ret = new MessageWrapper(); string jsonMessageString = JsonConvert.SerializeObject(eventMessage); if ((jsonMessageString.Length * sizeof(char)) < MaxMessageSize) { ConfigureWrapperForSimpleMessage(ret, jsonMessageString); } else { byte[] bytes = jsonMessageString.Zip(); if (bytes.LongLength <= MaxMessageSize) { ConfigureWrapperForZippedMessage(ret, bytes); } else { switch (veryLargeMessageStrategy) { case VeryLargeMessageStrategy.Chunk: ConfigureWrapperForChunks(ret, bytes); break; case VeryLargeMessageStrategy.Storage: ConfigureWrapperForStorage(ret, bytes); break; default: break; } } } return(ret); }
/// <summary> /// Construtor to set storage infomrations /// </summary> /// <param name="storageContainerName">Storage Container Name</param> /// <param name="blobStorageConnectionString">Storage connection string</param> /// <param name="strategy">Strategy to use with large messages</param> public StorageSettingData(string storageContainerName, string blobStorageConnectionString, VeryLargeMessageStrategy strategy) { StorageContainerName = storageContainerName; BlobStorageConnectionString = blobStorageConnectionString; Strategy = strategy; }