public async Task <bool> UpdateConfigAsync(T config, CancellationToken token) { bool toReturn = false; string serialized = Newtonsoft.Json.JsonConvert.SerializeObject(config); string typeName = Util.Util.GetTypeName(typeof(T)); PersistedMessage oldConfig = await db.PeekNextAsync("config", token); PersistedMessage newConfig = new PersistedMessage(serialized) { Headers = new Dictionary <string, string>() , MessageType = typeName , Ordinal = 0 , DateStamp = DateTime.UtcNow , Status = PersistedMessageStatusOptions.ReadyToProcess , Queue = "config" }; newConfig.Routes.Add(new Route() { EndPointName = "config", EndPointType = Publish.EndPointTypeOptions.Handler , Routed = DateTime.UtcNow }); toReturn = await db.PersistAsync(new List <PersistedMessage>() { newConfig }, token); //peek pulls latest anyway, so if this fails, no harm done if (oldConfig != null) { await db.MarkAsync(oldConfig.Id, PersistedMessageStatusOptions.Marked, token); } return(toReturn); }