CAP v2.1+ provides the dashboard pages, you can easily view the sent and received messages. In addition, you can also view the message status in real time on the dashboard.
CAP v2.1+ provides the dashboard pages, you can easily view the sent and received messages. In addition, you can also view the message status in real time on the dashboard. Use the following command to install the Dashboard in your project.
```
PM> Install-Package DotNetCore.Dashboard
```
In the distributed environment, the dashboard built-in integrated [Consul](http://consul.io) as a node discovery, while the realization of the gateway agent function, you can also easily view the node or other node data, It's like you are visiting local resources.
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
samples/Sample.AzureServiceBus.InMemory/Sample.AzureServiceBus.InMemory.csproj → samples/Sample.Kafka.InMemory/Sample.Kafka.InMemory.csprojZobrazit soubor
Console.WriteLine($@"A message of type {type} failed after executing {x.FailedRetryCount} several times, requiring manual troubleshooting. Message name: {name}, message body: {content}");
Console.WriteLine(
$@"A message of type {type} failed after executing {x.FailedRetryCount} several times, requiring manual troubleshooting. Message name: {msg.GetName()}");
};
});
services.AddMvc();
services.AddControllers();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app)
{
app.UseMvc();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
+ 1- 1
samples/Sample.RabbitMQ.MySql/appsettings.jsonZobrazit soubor
@@ -2,7 +2,7 @@
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug"
"Default": "Error"
}
}
}
+ 40- 0
samples/Sample.RabbitMQ.SqlServer/AppDbContext.csZobrazit soubor
@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore;
namespace Sample.RabbitMQ.SqlServer
{
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public override string ToString()
{
return $"Name:{Name}, Id:{Id}";
}
}
public class Person2
{
public int Id { get; set; }
public string Name { get; set; }
public override string ToString()
{
return $"Name:{Name}, Id:{Id}";
}
}
public class AppDbContext : DbContext
{
public const string ConnectionString = "Server=192.168.2.120;Database=captest;User Id=sa;Password=P@ssw0rd;";
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AppDbContext>();
services.AddCap(x =>
{
x.UseEntityFramework<AppDbContext>();
x.UseRabbitMQ("192.168.2.120");
x.UseDashboard();
x.FailedRetryCount = 5;
x.FailedThresholdCallback = (type, msg) =>
{
Console.WriteLine(
$@"A message of type {type} failed after executing {x.FailedRetryCount} several times, requiring manual troubleshooting. Message name: {msg.GetName()}");
};
});
services.AddControllers();
}
public void Configure(IApplicationBuilder app)
{
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
+ 8- 0
samples/Sample.RabbitMQ.SqlServer/appsettings.jsonZobrazit soubor
src/DotNetCore.CAP.AzureServiceBus/IPublishMessageSender.AzureServiceBus.cs → src/DotNetCore.CAP.AzureServiceBus/ITransport.AzureServiceBus.csZobrazit soubor
@@ -2,18 +2,18 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using DotNetCore.CAP.Internal;
using DotNetCore.CAP.Processor.States;
using DotNetCore.CAP.Messages;
using DotNetCore.CAP.Transport;
using Microsoft.Azure.ServiceBus;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace DotNetCore.CAP.AzureServiceBus
{
internal class AzureServiceBusPublishMessageSender : BasePublishMessageSender
internal class AzureServiceBusTransport : ITransport
{
private readonly SemaphoreSlim _connectionLock = new SemaphoreSlim(initialCount: 1, maxCount: 1);
src/DotNetCore.CAP/Dashboard/CommandDispatcher.cs → src/DotNetCore.CAP.Dashboard/CommandDispatcher.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/css/bootstrap.min.css → src/DotNetCore.CAP.Dashboard/Content/css/bootstrap.min.cssZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/css/cap.css → src/DotNetCore.CAP.Dashboard/Content/css/cap.cssZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/css/jsonview.min.css → src/DotNetCore.CAP.Dashboard/Content/css/jsonview.min.cssZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/css/rickshaw.min.css → src/DotNetCore.CAP.Dashboard/Content/css/rickshaw.min.cssZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/fonts/glyphicons-halflings-regular.eot → src/DotNetCore.CAP.Dashboard/Content/fonts/glyphicons-halflings-regular.eotZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/fonts/glyphicons-halflings-regular.svg → src/DotNetCore.CAP.Dashboard/Content/fonts/glyphicons-halflings-regular.svgZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/fonts/glyphicons-halflings-regular.ttf → src/DotNetCore.CAP.Dashboard/Content/fonts/glyphicons-halflings-regular.ttfZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/fonts/glyphicons-halflings-regular.woff → src/DotNetCore.CAP.Dashboard/Content/fonts/glyphicons-halflings-regular.woffZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/fonts/glyphicons-halflings-regular.woff2 → src/DotNetCore.CAP.Dashboard/Content/fonts/glyphicons-halflings-regular.woff2Zobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/js/bootstrap.min.js → src/DotNetCore.CAP.Dashboard/Content/js/bootstrap.min.jsZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/js/cap.js → src/DotNetCore.CAP.Dashboard/Content/js/cap.jsZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/js/d3.layout.min.js → src/DotNetCore.CAP.Dashboard/Content/js/d3.layout.min.jsZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/js/d3.min.js → src/DotNetCore.CAP.Dashboard/Content/js/d3.min.jsZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/js/jquery-2.1.4.min.js → src/DotNetCore.CAP.Dashboard/Content/js/jquery-2.1.4.min.jsZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/js/jsonview.min.js → src/DotNetCore.CAP.Dashboard/Content/js/jsonview.min.jsZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/js/moment-with-locales.min.js → src/DotNetCore.CAP.Dashboard/Content/js/moment-with-locales.min.jsZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/js/moment.min.js → src/DotNetCore.CAP.Dashboard/Content/js/moment.min.jsZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/js/rickshaw.min.js → src/DotNetCore.CAP.Dashboard/Content/js/rickshaw.min.jsZobrazit soubor
src/DotNetCore.CAP/Dashboard/Content/resx/Strings.Designer.cs → src/DotNetCore.CAP.Dashboard/Content/resx/Strings.Designer.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/GatewayProxy/DownstreamUrl.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/DownstreamUrl.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/GatewayProxy/GatewayProxyMiddleware.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/GatewayProxyMiddleware.csZobrazit soubor
@@ -9,7 +9,7 @@ using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using DotNetCore.CAP.Dashboard.GatewayProxy.Requester;
using DotNetCore.CAP.NodeDiscovery;
using DotNetCore.CAP.Dashboard.NodeDiscovery;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestMapper.Default.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/IRequestMapper.Default.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestMapper.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/IRequestMapper.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/HttpClientBuilder.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/HttpClientBuilder.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/HttpClientHttpRequester.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/HttpClientHttpRequester.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/IHttpClient.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/IHttpClient.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/IHttpClientBuilder.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/IHttpClientBuilder.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/IHttpClientCache.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/IHttpClientCache.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/IHttpRequester.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/IHttpRequester.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/MemoryHttpClientCache.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/MemoryHttpClientCache.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/HtmlHelper.cs → src/DotNetCore.CAP.Dashboard/HtmlHelper.csZobrazit soubor
@@ -10,8 +10,8 @@ using System.Text;
using System.Text.RegularExpressions;
using DotNetCore.CAP.Dashboard.Pages;
using DotNetCore.CAP.Dashboard.Resources;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models;
using DotNetCore.CAP.Internal;
using DotNetCore.CAP.Messages;
using Microsoft.Extensions.Internal;
namespace DotNetCore.CAP.Dashboard
src/DotNetCore.CAP/Dashboard/IDashboardAuthorizationFilter.cs → src/DotNetCore.CAP.Dashboard/IDashboardAuthorizationFilter.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/IDashboardDispatcher.cs → src/DotNetCore.CAP.Dashboard/IDashboardDispatcher.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/JsonDispatcher.cs → src/DotNetCore.CAP.Dashboard/JsonDispatcher.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/LocalRequestsOnlyAuthorizationFilter.cs → src/DotNetCore.CAP.Dashboard/LocalRequestsOnlyAuthorizationFilter.csZobrazit soubor
@@ -2,42 +2,40 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Threading.Tasks;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Internal;
namespace DotNetCore.CAP.Dashboard
{
public class LocalRequestsOnlyAuthorizationFilter : IDashboardAuthorizationFilter
{
#pragma warning disable 1998
public async Task<bool> AuthorizeAsync(DashboardContext context)
#pragma warning restore 1998
public Task<bool> AuthorizeAsync(DashboardContext context)
{
var ipAddress = context.Request.RemoteIpAddress;
// if unknown, assume not local
if (string.IsNullOrEmpty(ipAddress))
{
return false;
return Task.FromResult(false);
}
// check if localhost
if (ipAddress == "127.0.0.1" || ipAddress == "0.0.0.1")
{
return true;
return Task.FromResult(true);
}
// compare with local address
if (ipAddress == context.Request.LocalIpAddress)
{
return true;
return Task.FromResult(true);
}
// check if private ip
if (Helper.IsInnerIP(ipAddress))
{
return true;
return Task.FromResult(true);
}
return false;
return Task.FromResult(false);
}
}
}
src/DotNetCore.CAP/Dashboard/MenuItem.cs → src/DotNetCore.CAP.Dashboard/MenuItem.csZobrazit soubor
src/DotNetCore.CAP/Dashboard/MessageHistoryRenderer.cs → src/DotNetCore.CAP.Dashboard/MessageHistoryRenderer.csZobrazit soubor