‹ 首页

abp-microservices

@burakdmir · 收录于 昨天 · 上游提交 2 周前

ABP Framework v10.x (10.4/10.5) microservice solution: structure (apps/gateways/services), Integration Services [IntegrationService], distributed events (RabbitMQ Outbox/Inbox), YARP gateway, OpenIddict auth server, Entity Cache, database-per-service. Use when you need microservices or inter-service communication in ABP.

适合你,如果你正用 ABP 框架构建微服务系统

/ 通过 npx 安装 校验哈希
npx oh-my-skill add burakdmir/abp-skills/abp-microservices
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- burakdmir/abp-skills/abp-microservices
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify burakdmir/abp-skills/abp-microservices
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
13GitHub stars
~1.1K上下文体积 · 单文件
索引托管

怎么用

商店整理自技能原文 · 版本 ce71259 · 表述以原文为准
它做什么

这个技能能让 Claude 指导你搭建 ABP 框架 v10.x 的微服务系统,包括项目结构、服务间同步调用(集成服务)和异步通知(分布式事件)、YARP 网关、OpenIddict 认证服务器、实体缓存等。

什么时候触发

当你询问如何构建 ABP 微服务、配置服务间通信、使用集成服务或分布式事件时,Claude 会触发这个技能。

装好后可以这样说
Claude 会解释集成服务的定义、暴露和代理生成。
Claude 会指导你创建 ETO、发布和订阅事件。
技能原文 SKILL.md作者撰写 · MIT · ce71259

ABP Framework — Microservices

ABP Framework v10.x (10.4/10.5) microservice solution template (Business+ license). A distributed system with synchronous (Integration Services) and asynchronous (distributed events) inter-service communication, a YARP gateway, and an OpenIddict auth server.

Trigger
  • "ABP microservice"
  • "ABP microservices"
  • "ABP integration service"
  • "ABP inter-service communication"
  • "ABP distributed event"
  • "ABP YARP gateway"
  • "ABP auth server"
Solution Structure
MyMicroservice/
├── apps/                      # UI applications
│   ├── web/                   # Web application
│   ├── public-web/            # Public site
│   └── auth-server/           # Authentication server (OpenIddict)
├── gateways/                  # BFF — one gateway per UI
│   └── web-gateway/           # YARP reverse proxy
├── services/                  # Microservices
│   ├── administration/        # Permission, setting, feature
│   ├── identity/              # User, role
│   └── [business-services]/   # Your own business services
└── etc/
    ├── docker/                # docker compose for local infra
    └── helm/                  # Kubernetes deployment
Microservice Structure (NOT Layered!)

Each microservice has a simplified single-project structure:

services/ordering/
├── OrderingService/                # Main project
│   ├── Entities/
│   ├── Services/
│   ├── IntegrationServices/        # For inter-service communication
│   ├── Data/                       # DbContext (IHasEventInbox, IHasEventOutbox)
│   └── OrderingServiceModule.cs
├── OrderingService.Contracts/      # Interface, DTO, ETO (shared)
└── OrderingService.Tests/
Synchronous Communication — Integration Services

For synchronous inter-service calls, use an Integration Service, not a regular application service.

1. Provider — define the Integration Service
// In the CatalogService.Contracts project
[IntegrationService]
public interface IProductIntegrationService : IApplicationService
{
    Task<List<ProductDto>> GetProductsByIdsAsync(List<Guid> ids);
}

// In the CatalogService project
[IntegrationService]
public class ProductIntegrationService : ApplicationService, IProductIntegrationService
{
    public async Task<List<ProductDto>> GetProductsByIdsAsync(List<Guid> ids)
    {
        var products = await _productRepository.GetListAsync(p => ids.Contains(p.Id));
        return ObjectMapper.Map<List<Product>, List<ProductDto>>(products);
    }
}
2. Provider — expose the Integration Services
// CatalogServiceModule.cs
Configure<AbpAspNetCoreMvcOptions>(options =>
{
    options.ExposeIntegrationServices = true;
});
3-4. Consumer — reference Contracts + generate proxy
abp generate-proxy -t csharp -u http://localhost:44361 -m catalog --without-contracts
5. Consumer — register the HTTP client proxy
[DependsOn(typeof(CatalogServiceContractsModule))]
public class OrderingServiceModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddStaticHttpClientProxies(
            typeof(CatalogServiceContractsModule).Assembly, "CatalogService");
    }
}
6. Consumer — Remote service URL
// appsettings.json
"RemoteServices": {
    "CatalogService": { "BaseUrl": "http://localhost:44361" }
}
7. Use it
public class OrderAppService : ApplicationService
{
    private readonly IProductIntegrationService _productIntegrationService;

    public async Task<List<OrderDto>> GetListAsync()
    {
        var orders = await _orderRepository.GetListAsync();
        var productIds = orders.Select(o => o.ProductId).Distinct().ToList();
        var products = await _productIntegrationService.GetProductsByIdsAsync(productIds);
        // ...
    }
}
Why an Integration Service? Application services are for the UI (with different authorization/validation/optimization needs). Integration services are designed for service-to-service communication. When: Immediate response + data needed to complete the current operation (e.g. product details to show in an order list).
Asynchronous Communication — Distributed Events (RabbitMQ)

For loosely coupled state notifications.

// ETO — in the Contracts project
[EventName("Product.StockChanged")]
public class StockCountChangedEto { public Guid ProductId { get; set; } public int NewCount { get; set; } }

// Publish
await _distributedEventBus.PublishAsync(new StockCountChangedEto { ... });

// Subscribe (in another service)
public class StockChangedHandler : IDistributedEventHandler<StockCountChangedEto>, ITransientDependency
{
    public async Task HandleEventAsync(StockCountChangedEto eventData) { }
}
The DbContext must implement IHasEventInbox and IHasEventOutbox for the Outbox/Inbox pattern. When: State change notifications (order placed, stock updated), operations that don't require an immediate response and where services should remain independent.
Performance — Entity Cache
// Registration
context.Services.AddEntityCache<Product, ProductDto, Guid>();

// Usage (automatically invalidated when the entity changes)
private readonly IEntityCache<ProductDto, Guid> _productCache;
public Task<ProductDto> GetProductAsync(Guid id) => _productCache.GetAsync(id);
Built-in Infrastructure
  • RabbitMQ — Distributed events (Outbox/Inbox)
  • Redis — Distributed cache + locking
  • YARP — API Gateway
  • OpenIddict — Auth server
Best Practices
  1. Choose the right communication — synchronous: queries needing immediate data; asynchronous: notification/state change
  2. Use Integration Services — not application services for inter-service calls
  3. Cache remote data — Entity Cache / IDistributedCache
  4. Share only Contracts — never share the implementation
  5. Idempotent handlers — events can be delivered multiple times
  6. Database-per-service — each service owns its own database
Related
  • [Framework Core](../abp-framework/SKILL.md) — solution templates
  • [API](../abp-api/SKILL.md) — Integration Services, dynamic proxy
  • [Infrastructure](../abp-infrastructure/SKILL.md) — distributed event bus, Redis cache
  • [Authorization](../abp-authorization/SKILL.md) — OpenIddict, permission
  • [Deployment](../abp-deployment/SKILL.md) — Docker, Kubernetes/Helm, gateway
  • ABP Docs: https://abp.io/docs/latest/solution-templates/microservice
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。