public void Save(MessageLogEntity entity)
        {
            var table     = this.tableClient.GetTableReference(this.tableName);
            var operation = TableOperation.InsertOrReplace(entity);

            table.Execute(operation);
        }
Exemplo n.º 2
0
        public void Save(MessageLogEntity entity)
        {
            TableBatchOperation batchOperation = new TableBatchOperation();
            this.retryPolicy.ExecuteAction(() =>
            {
                var context = this.tableClient.GetTableReference(this.tableName);
                batchOperation.Insert(entity);

                try
                {
                    context.ExecuteBatch(batchOperation);
                }
                catch
                {

                }
            });
        }
Exemplo n.º 3
0
        public void Save(MessageLogEntity entity)
        {
            TableBatchOperation batchOperation = new TableBatchOperation();

            this.retryPolicy.ExecuteAction(() =>
            {
                var context = this.tableClient.GetTableReference(this.tableName);
                batchOperation.Insert(entity);


                try
                {
                    context.ExecuteBatch(batchOperation);
                }
                catch
                {
                }
            });
        }
        public void Save(MessageLogEntity entity)
        {
            retryPolicy.ExecuteAction(() => {
                var context = tableClient.GetDataServiceContext();

                context.AddObject(tableName, entity);

                try {
                    context.SaveChanges();
                } catch (DataServiceRequestException dsre) {
                    var clientException = dsre.InnerException as DataServiceClientException;
                    // If we get a conflict, we ignore it as we've already saved the message,
                    // making this log idempotent.
                    if (clientException == null || clientException.StatusCode != (int)HttpStatusCode.Conflict)
                    {
                        throw;
                    }
                }
            });
        }
        public void GeneratePastEventLogMessagesForConferenceManagement(
            CloudTableClient messageLogClient, string messageLogName,
            string conferenceManagementConnectionString,
            IMetadataProvider metadataProvider, ITextSerializer serializer)
        {
            retryPolicy.ExecuteAction(() => messageLogClient.CreateTableIfNotExist(messageLogName));

            // set the creation date to just before releasing V1 (previous month).
            var eventCreationDate = new DateTime(2012, 04, 01, 0, 0, 0, DateTimeKind.Utc);

            var generatedEvents = this.GenerateMissedConferenceManagementIntegrationEvents(conferenceManagementConnectionString);
            foreach (var evt in generatedEvents)
            {
                // generate events in ascending order. If there is a conflict when saving (currently silently swallowed by AzureEventLogWriter), 
                // then the migration process is being run for the second time, which is wrong.
                // TODO: what happens if the process crashes middleway.
                eventCreationDate = eventCreationDate.AddSeconds(1);
                var metadata = metadataProvider.GetMetadata(evt);
                var entry = new MessageLogEntity
                {
                    PartitionKey = eventCreationDate.ToString("yyyMM"),
                    // could have a prefix instead of suffix to be able to search
                    RowKey = eventCreationDate.Ticks.ToString("D20") + "_Generated",
                    CreationDate = eventCreationDate.ToString("o"),
                    MessageId = null,
                    CorrelationId = null,
                    SourceType = null,
                    SourceId = evt.SourceId.ToString(),
                    AssemblyName = metadata[StandardMetadata.AssemblyName],
                    FullName = metadata[StandardMetadata.FullName],
                    Namespace = metadata[StandardMetadata.Namespace],
                    TypeName = metadata[StandardMetadata.TypeName],
                    Kind = StandardMetadata.EventKind,
                    Payload = serializer.Serialize(evt),
                };

                var context = messageLogClient.GetDataServiceContext();
                context.AddObject(messageLogName, entry);
                retryPolicy.ExecuteAction(() => context.SaveChanges());
            }
        }
        public void Save(MessageLogEntity entity)
        {
            this.retryPolicy.ExecuteAction(() =>
            {
                var context = this.tableClient.GetDataServiceContext();

                context.AddObject(this.tableName, entity);

                try
                {
                    context.SaveChanges();
                }
                catch (DataServiceRequestException dsre)
                {
                    var clientException = dsre.InnerException as DataServiceClientException;
                    // If we get a conflict, we ignore it as we've already saved the message, 
                    // making this log idempotent.
                    if (clientException == null || clientException.StatusCode != (int)HttpStatusCode.Conflict)
                        throw;
                }
            });
        }
Exemplo n.º 7
0
        private void Save(IEvent @event, DateTime enqueueTime)
        {
            var message = new MessageLogEntity
            {
                Payload = this.serializer.Serialize(@event),
                PartitionKey = enqueueTime.ToString("yyyMM"),
                RowKey = enqueueTime.Ticks.ToString("D20") + "_" + @event.GetHashCode(),
                MessageId = Guid.NewGuid().ToString(),
                CorrelationId = Guid.NewGuid().ToString(),
            };

            foreach (var metadata in this.metadata.GetMetadata(@event))
            {
                message.GetType().GetProperty(metadata.Key).SetValue(message, metadata.Value, null);
            }

            this.writer.Save(message);
        }
Exemplo n.º 8
0
 public void Save(MessageLogEntity entity)
 {
     var table = this.tableClient.GetTableReference(this.tableName);
     var operation = TableOperation.InsertOrReplace(entity);
     table.Execute(operation);
 }