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.csprojVoir le fichier
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.jsonVoir le fichier
@@ -2,7 +2,7 @@
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug"
"Default": "Error"
}
}
}
+ 40- 0
samples/Sample.RabbitMQ.SqlServer/AppDbContext.csVoir le fichier
@@ -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.jsonVoir le fichier
src/DotNetCore.CAP.AzureServiceBus/IPublishMessageSender.AzureServiceBus.cs → src/DotNetCore.CAP.AzureServiceBus/ITransport.AzureServiceBus.csVoir le fichier
@@ -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.csVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/css/bootstrap.min.css → src/DotNetCore.CAP.Dashboard/Content/css/bootstrap.min.cssVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/css/cap.css → src/DotNetCore.CAP.Dashboard/Content/css/cap.cssVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/css/jsonview.min.css → src/DotNetCore.CAP.Dashboard/Content/css/jsonview.min.cssVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/css/rickshaw.min.css → src/DotNetCore.CAP.Dashboard/Content/css/rickshaw.min.cssVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/fonts/glyphicons-halflings-regular.eot → src/DotNetCore.CAP.Dashboard/Content/fonts/glyphicons-halflings-regular.eotVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/fonts/glyphicons-halflings-regular.svg → src/DotNetCore.CAP.Dashboard/Content/fonts/glyphicons-halflings-regular.svgVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/fonts/glyphicons-halflings-regular.ttf → src/DotNetCore.CAP.Dashboard/Content/fonts/glyphicons-halflings-regular.ttfVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/fonts/glyphicons-halflings-regular.woff → src/DotNetCore.CAP.Dashboard/Content/fonts/glyphicons-halflings-regular.woffVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/fonts/glyphicons-halflings-regular.woff2 → src/DotNetCore.CAP.Dashboard/Content/fonts/glyphicons-halflings-regular.woff2Voir le fichier
src/DotNetCore.CAP/Dashboard/Content/js/bootstrap.min.js → src/DotNetCore.CAP.Dashboard/Content/js/bootstrap.min.jsVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/js/cap.js → src/DotNetCore.CAP.Dashboard/Content/js/cap.jsVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/js/d3.layout.min.js → src/DotNetCore.CAP.Dashboard/Content/js/d3.layout.min.jsVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/js/d3.min.js → src/DotNetCore.CAP.Dashboard/Content/js/d3.min.jsVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/js/jquery-2.1.4.min.js → src/DotNetCore.CAP.Dashboard/Content/js/jquery-2.1.4.min.jsVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/js/jsonview.min.js → src/DotNetCore.CAP.Dashboard/Content/js/jsonview.min.jsVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/js/moment-with-locales.min.js → src/DotNetCore.CAP.Dashboard/Content/js/moment-with-locales.min.jsVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/js/moment.min.js → src/DotNetCore.CAP.Dashboard/Content/js/moment.min.jsVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/js/rickshaw.min.js → src/DotNetCore.CAP.Dashboard/Content/js/rickshaw.min.jsVoir le fichier
src/DotNetCore.CAP/Dashboard/Content/resx/Strings.Designer.cs → src/DotNetCore.CAP.Dashboard/Content/resx/Strings.Designer.csVoir le fichier
src/DotNetCore.CAP/Dashboard/GatewayProxy/DownstreamUrl.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/DownstreamUrl.csVoir le fichier
src/DotNetCore.CAP/Dashboard/GatewayProxy/GatewayProxyMiddleware.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/GatewayProxyMiddleware.csVoir le fichier
@@ -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.csVoir le fichier
src/DotNetCore.CAP/Dashboard/GatewayProxy/IRequestMapper.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/IRequestMapper.csVoir le fichier
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/HttpClientBuilder.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/HttpClientBuilder.csVoir le fichier
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/HttpClientHttpRequester.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/HttpClientHttpRequester.csVoir le fichier
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/IHttpClient.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/IHttpClient.csVoir le fichier
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/IHttpClientBuilder.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/IHttpClientBuilder.csVoir le fichier
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/IHttpClientCache.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/IHttpClientCache.csVoir le fichier
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/IHttpRequester.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/IHttpRequester.csVoir le fichier
src/DotNetCore.CAP/Dashboard/GatewayProxy/Requester/MemoryHttpClientCache.cs → src/DotNetCore.CAP.Dashboard/GatewayProxy/Requester/MemoryHttpClientCache.csVoir le fichier
src/DotNetCore.CAP/Dashboard/HtmlHelper.cs → src/DotNetCore.CAP.Dashboard/HtmlHelper.csVoir le fichier
@@ -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.csVoir le fichier
src/DotNetCore.CAP/Dashboard/IDashboardDispatcher.cs → src/DotNetCore.CAP.Dashboard/IDashboardDispatcher.csVoir le fichier
src/DotNetCore.CAP/Dashboard/JsonDispatcher.cs → src/DotNetCore.CAP.Dashboard/JsonDispatcher.csVoir le fichier
src/DotNetCore.CAP/Dashboard/LocalRequestsOnlyAuthorizationFilter.cs → src/DotNetCore.CAP.Dashboard/LocalRequestsOnlyAuthorizationFilter.csVoir le fichier
@@ -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.csVoir le fichier
src/DotNetCore.CAP/Dashboard/MessageHistoryRenderer.cs → src/DotNetCore.CAP.Dashboard/MessageHistoryRenderer.csVoir le fichier