private async Task <IEnumerable <MediumMessage> > GetMessagesOfNeedRetryAsync(string tableName) { var fourMinAgo = DateTime.Now.AddMinutes(-4); var sql = $"SELECT \"Id\",\"Content\",\"Retries\",\"Added\" FROM \"{tableName}\" WHERE \"Retries\"<{_capOptions.Value.FailedRetryCount} " + $"AND \"Version\"='{_capOptions.Value.Version}' AND \"Added\"<:P_FourMinAgo AND (\"StatusName\" = '{StatusName.Failed}' OR \"StatusName\" = '{StatusName.Scheduled}') AND ROWNUM <= 200"; using var connection = new OracleConnection(_options.Value.ConnectionString); var result = connection.ExecuteReader(sql, reader => { var messages = new List <MediumMessage>(); while (reader.Read()) { messages.Add(new MediumMessage { DbId = reader.GetInt64(0).ToString(), Origin = StringSerializer.DeSerialize(reader.GetString(1)), Retries = reader.GetInt32(2), Added = reader.GetDateTime(3) }); } return(messages); }, new OracleParameter(":P_FourMinAgo", fourMinAgo)); return(result); }
public async Task <IEnumerable <MediumMessage> > GetReceivedMessagesOfNeedRetry() { var fourMinAgo = DateTime.Now.AddMinutes(-4).ToString("O"); var sql = $"SELECT TOP (200) * FROM {_recName} WITH (readpast) WHERE Retries<{_capOptions.Value.FailedRetryCount} " + $"AND Version='{_capOptions.Value.Version}' AND Added<'{fourMinAgo}' AND (StatusName = '{StatusName.Failed}' OR StatusName = '{StatusName.Scheduled}')"; var result = new List <MediumMessage>(); // using var connection = new SqlConnection(_options.Value.ConnectionString); var connection = this.DbConnection; var reader = await connection.ExecuteReaderAsync(sql); while (reader.Read()) { result.Add(new MediumMessage { DbId = reader.GetInt64(0).ToString(), Origin = StringSerializer.DeSerialize(reader.GetString(4)), Retries = reader.GetInt32(5), Added = reader.GetDateTime(6) }); } return(result); }
private async Task <IEnumerable <MediumMessage> > GetMessagesOfNeedRetryAsync(string tableName) { var fourMinAgo = DateTime.Now.AddMinutes(-4).ToString("O"); var sql = $"SELECT TOP (200) Id, Content, Retries, Added FROM {tableName} WITH (readpast) WHERE Retries<{_capOptions.Value.FailedRetryCount} " + $"AND Version='{_capOptions.Value.Version}' AND Added<'{fourMinAgo}' AND (StatusName = '{StatusName.Failed}' OR StatusName = '{StatusName.Scheduled}')"; List <MediumMessage> result; using (var connection = new SqlConnection(_options.Value.ConnectionString)) { result = connection.ExecuteReader(sql, reader => { var messages = new List <MediumMessage>(); while (reader.Read()) { messages.Add(new MediumMessage { DbId = reader.GetInt64(0).ToString(), Origin = StringSerializer.DeSerialize(reader.GetString(1)), Retries = reader.GetInt32(2), Added = reader.GetDateTime(3) }); } return(messages); }); } return(await Task.FromResult(result)); }
private async Task <IEnumerable <MediumMessage> > GetMessagesOfNeedRetryAsync(string sql) { List <MediumMessage> result; using (var connection = new SqlConnection(_options.Value.ConnectionString)) { result = connection.ExecuteReader(sql, reader => { var messages = new List <MediumMessage>(); while (reader.Read()) { messages.Add(new MediumMessage { DbId = reader.GetInt64(0).ToString(), Origin = StringSerializer.DeSerialize(reader.GetString(1)), Retries = reader.GetInt32(2), Added = reader.GetDateTime(3) }); } return(messages); }); } return(await Task.FromResult(result)); }
private async Task <IEnumerable <MediumMessage> > GetMessagesOfNeedRetryAsync(string tableName) { var fourMinAgo = DateTime.Now.AddMinutes(-4).ToString("O"); var sql = $"SELECT `Id`,`Content`,`Retries`,`Added` FROM `{tableName}` WHERE `Retries`<{_capOptions.Value.FailedRetryCount} " + $"AND `Version`='{_capOptions.Value.Version}' AND `Added`<'{fourMinAgo}' AND (`StatusName` = '{StatusName.Failed}' OR `StatusName` = '{StatusName.Scheduled}') LIMIT 200;"; await using var connection = new MySqlConnection(_options.Value.ConnectionString); var result = connection.ExecuteReader(sql, reader => { var messages = new List <MediumMessage>(); while (reader.Read()) { messages.Add(new MediumMessage { DbId = reader.GetInt64(0).ToString(), Origin = StringSerializer.DeSerialize(reader.GetString(1)), Retries = reader.GetInt32(2), Added = reader.GetDateTime(3) }); } return(messages); }); return(result); }
public async Task <IEnumerable <MediumMessage> > GetReceivedMessagesOfNeedRetry() { var fourMinsAgo = DateTime.Now.AddMinutes(-4).ToString("O"); var sql = $"SELECT * FROM `{_initializer.GetReceivedTableName()}` WHERE `Retries` < @Retries AND `Version` = @Version AND `Added` < @Added AND (`StatusName` = @FailedStatusName OR `StatusName` = @ScheduledStatusName) LIMIT 200;"; var sqlParam = new { FailedStatusName = nameof(StatusName.Failed), ScheduledStatusName = nameof(StatusName.Scheduled), Retries = _capOptions.Value.FailedRetryCount, Version = _capOptions.Value.Version, Added = fourMinsAgo }; var result = new List <MediumMessage>(); using (var connection = new SqliteConnection(_options.Value.ConnectionString)) { var reader = await connection.ExecuteReaderAsync(sql, sqlParam); while (reader.Read()) { result.Add(new MediumMessage { DbId = reader.GetInt64(0).ToString(), Origin = StringSerializer.DeSerialize(reader.GetString(3)), Retries = reader.GetInt32(4), Added = reader.GetDateTime(5) }); } return(result); } }
public async Task <IEnumerable <MediumMessage> > GetReceivedMessagesOfNeedRetry() { var fourMinAgo = DateTime.Now.AddMinutes(-4).ToString("O"); var sql = $"SELECT * FROM `{_initializer.GetReceivedTableName()}` WHERE `Retries`<{_capOptions.Value.FailedRetryCount} AND `Version`='{_capOptions.Value.Version}' AND `Added`<'{fourMinAgo}' AND (`StatusName` = '{StatusName.Failed}' OR `StatusName` = '{StatusName.Scheduled}') LIMIT 200;"; var result = new List <MediumMessage>(); var connection = this.DbConnection; var reader = await connection.ExecuteReaderAsync(sql, transaction : DbTransaction); while (reader.Read()) { result.Add(new MediumMessage { DbId = reader.GetInt64(0).ToString(), Origin = StringSerializer.DeSerialize(reader.GetString(4)), Retries = reader.GetInt32(5), Added = reader.GetDateTime(6) }); } return(result); }
public object DeepCopy(object value) { if (value == null) { return(null); } return(StringSerializer <originalType> .DeSerialize(StringSerializer <originalType> .Serialize((originalType)value))); }
public async Task Get_Received_Message_Test() { var message = await _monitoring.GetReceivedMessageAsync(_receivedMessageId); message.Origin = StringSerializer.DeSerialize(message.Content); var headerExists = message.Origin.Headers.ContainsKey("test-header"); Assert.True(headerExists); Assert.Equal("test-value", message.Origin.Headers["test-header"]); }
public Task <IEnumerable <MediumMessage> > GetReceivedMessagesOfNeedRetry() { var ret = ReceivedMessages .Find(x => x.Retries < _capOptions.Value.FailedRetryCount && x.Added < DateTime.Now.AddSeconds(-10) && (x.StatusName == StatusName.Scheduled || x.StatusName == StatusName.Failed)) .Take(200) .Select(x => (MediumMessage)x); foreach (var message in ret) { message.Origin = StringSerializer.DeSerialize(message.Content); } return(Task.FromResult(ret)); }
private async Task <IEnumerable <MediumMessage> > GetMessagesOfNeedRetryAsync(string tableName) { var list = await _capRepository.GetMessagesOfNeedRetryAsync(tableName, _capOptions.Value.FailedRetryCount, _capOptions.Value.Version, DateTime.Now.AddMinutes(-4).ToString("O")); var messages = new List <MediumMessage>(); foreach (var messagesOfNeedRetry in list) { messages.Add(new MediumMessage { DbId = messagesOfNeedRetry.Id.ToString(), Origin = StringSerializer.DeSerialize(messagesOfNeedRetry.Content), Retries = messagesOfNeedRetry.Retries, Added = messagesOfNeedRetry.Added }); } return(messages); }
public async Task <IEnumerable <MediumMessage> > GetReceivedMessagesOfNeedRetry() { var fourMinAgo = DateTime.Now.AddMinutes(-4); var collection = _database.GetCollection <ReceivedMessage>(_options.Value.PublishedCollection); var queryResult = await collection .Find(x => x.Retries < _capOptions.Value.FailedRetryCount && x.Added < fourMinAgo && x.Version == _capOptions.Value.Version && (x.StatusName == nameof(StatusName.Failed) || x.StatusName == nameof(StatusName.Scheduled))) .Limit(200) .ToListAsync(); return(queryResult.Select(x => new MediumMessage { DbId = x.Id.ToString(), Origin = StringSerializer.DeSerialize(x.Content), Retries = x.Retries, Added = x.Added }).ToList()); }
public async Task <IEnumerable <MediumMessage> > GetPublishedMessagesOfNeedRetry() { var fourMinAgo = DateTime.Now.AddMinutes(-4).ToString("O"); var sql = $"SELECT * FROM {_pubName} WHERE \"Retries\"<{_capOptions.Value.FailedRetryCount} AND \"Version\"='{_capOptions.Value.Version}' AND \"Added\"<'{fourMinAgo}' AND (\"StatusName\"='{StatusName.Failed}' OR \"StatusName\"='{StatusName.Scheduled}') LIMIT 200;"; var result = new List <MediumMessage>(); var reader = await this.DbConnection.ExecuteReaderAsync(sql, transaction : DbTransaction); while (reader.Read()) { result.Add(new MediumMessage { DbId = reader.GetInt64(0).ToString(), Origin = StringSerializer.DeSerialize(reader.GetString(3)), Retries = reader.GetInt32(4), Added = reader.GetDateTime(5) }); } return(result); }
static DashboardRoutes() { Routes = new RouteCollection(); Routes.AddRazorPage("/", x => new HomePage()); Routes.Add("/stats", new JsonStats()); Routes.Add("/health", new OkStats()); #region Embedded static content Routes.Add("/js[0-9]+", new CombinedResourceDispatcher( "application/javascript", GetExecutingAssembly(), GetContentFolderNamespace("js"), Javascripts)); Routes.Add("/css[0-9]+", new CombinedResourceDispatcher( "text/css", GetExecutingAssembly(), GetContentFolderNamespace("css"), Stylesheets)); Routes.Add("/fonts/glyphicons-halflings-regular/eot", new EmbeddedResourceDispatcher( "application/vnd.ms-fontobject", GetExecutingAssembly(), GetContentResourceName("fonts", "glyphicons-halflings-regular.eot"))); Routes.Add("/fonts/glyphicons-halflings-regular/svg", new EmbeddedResourceDispatcher( "image/svg+xml", GetExecutingAssembly(), GetContentResourceName("fonts", "glyphicons-halflings-regular.svg"))); Routes.Add("/fonts/glyphicons-halflings-regular/ttf", new EmbeddedResourceDispatcher( "application/octet-stream", GetExecutingAssembly(), GetContentResourceName("fonts", "glyphicons-halflings-regular.ttf"))); Routes.Add("/fonts/glyphicons-halflings-regular/woff", new EmbeddedResourceDispatcher( "font/woff", GetExecutingAssembly(), GetContentResourceName("fonts", "glyphicons-halflings-regular.woff"))); Routes.Add("/fonts/glyphicons-halflings-regular/woff2", new EmbeddedResourceDispatcher( "font/woff2", GetExecutingAssembly(), GetContentResourceName("fonts", "glyphicons-halflings-regular.woff2"))); #endregion Embedded static content #region Razor pages and commands Routes.AddJsonResult("/published/message/(?<Id>.+)", x => { var id = long.Parse(x.UriMatch.Groups["Id"].Value); var message = x.Storage.GetMonitoringApi().GetPublishedMessageAsync(id) .GetAwaiter().GetResult(); return(message.Content); }); Routes.AddJsonResult("/received/message/(?<Id>.+)", x => { var id = long.Parse(x.UriMatch.Groups["Id"].Value); var message = x.Storage.GetMonitoringApi().GetReceivedMessageAsync(id) .GetAwaiter().GetResult(); return(message.Content); }); Routes.AddPublishBatchCommand( "/published/requeue", (client, messageId) => { var msg = client.Storage.GetMonitoringApi().GetPublishedMessageAsync(messageId) .GetAwaiter().GetResult(); msg.Origin = StringSerializer.DeSerialize(msg.Content); client.RequestServices.GetService <IDispatcher>().EnqueueToPublish(msg); }); Routes.AddPublishBatchCommand( "/received/requeue", (client, messageId) => { var msg = client.Storage.GetMonitoringApi().GetReceivedMessageAsync(messageId) .GetAwaiter().GetResult(); msg.Origin = StringSerializer.DeSerialize(msg.Content); client.RequestServices.GetService <ISubscribeDispatcher>().DispatchAsync(msg); }); Routes.AddRazorPage( "/published/(?<StatusName>.+)", x => new PublishedPage(x.UriMatch.Groups["StatusName"].Value)); Routes.AddRazorPage( "/received/(?<StatusName>.+)", x => new ReceivedPage(x.UriMatch.Groups["StatusName"].Value)); Routes.AddRazorPage("/subscribers", x => new SubscriberPage()); Routes.AddRazorPage("/nodes", x => { var id = x.Request.Cookies.ContainsKey("cap.node") ? x.Request.Cookies["cap.node"] : string.Empty; return(new NodePage(id)); }); Routes.AddRazorPage("/nodes/node/(?<Id>.+)", x => new NodePage(x.UriMatch.Groups["Id"].Value)); #endregion Razor pages and commands }
public object NullSafeGet(IDataReader rs, string[] names, object owner) { string txt = (string)NHibernateUtil.String.NullSafeGet(rs, names[0]); return StringSerializer<originalType>.DeSerialize(txt); }