Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jinzaz/jinzaz.cap.mqtt

dotnetcore/CAP的MQTT扩展支持
https://github.com/jinzaz/jinzaz.cap.mqtt

aspnetcore cap dotnetcore mqtt

Last synced: 27 days ago
JSON representation

dotnetcore/CAP的MQTT扩展支持

Awesome Lists containing this project

README

        

# jinzaz.CAP.MQTT
dotnetcore/CAP的MQTT扩展支持 ![Nuget](https://img.shields.io/nuget/v/jinzaz.CAP.MQTT) ![GitHub](https://img.shields.io/github/license/jinzaz/jinzaz.CAP.MQTT?color=blue) ![Nuget](https://img.shields.io/nuget/dt/jinzaz.CAP.MQTT?color=blue) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/jinzaz/jinzaz.CAP.MQTT)

```
// select a transport provider you are using, event log table will integrate into.

PM> Install-Package jinzaz.CAP.MQTT
```

### Configuration

#### .Net Core
```cs
public void ConfigureServices(IServiceCollection services)
{
//......

services.AddDbContext(); //Options, If you are using EF as the ORM

services.AddCap(x =>
{
x.UseEntityFramework();
x.UseMQTT(options => {
options.Server = "localhost";
options.Port = 6000;
options.UserName = "admin";
options.Password = "password";
options.ClientId = "z5fas51fs";
});
x.UseDashboard();
x.FailedRetryCount = 5;
x.FailedThresholdCallback = failed =>
{
var logger = failed.ServiceProvider.GetService>();
logger.LogError($@"A message of type {failed.MessageType} failed after executing {x.FailedRetryCount} several times,
requiring manual troubleshooting. Message name: {failed.Message.GetName()}");
};
});
}

```

#### .Net 6、7
```cs
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext(); //Options, If you are using EF as the ORM
// Add services to the container.
builder.Services.AddCap(x => {
x.UseEntityFramework();
x.UseMQTT(options => {
options.Server = "localhost";
options.Port = 6000;
options.UserName = "admin";
options.Password = "password";
options.ClientId = "z5fas51fs";
});
x.UseDashboard();
x.FailedRetryCount = 5;
x.FailedThresholdCallback = failed =>
{
var logger = failed.ServiceProvider.GetService>();
logger.LogError($@"A message of type {failed.MessageType} failed after executing {x.FailedRetryCount} several times,
requiring manual troubleshooting. Message name: {failed.Message.GetName()}");
};
});
builder.Services.AddControllers();

var app = builder.Build();

// Configure the HTTP request pipeline.

app.UseAuthorization();

app.MapControllers();

app.Run();
}
```