| name | abp-microservices |
| description | ABP Framework v10.x (10.4/10.5) microservice quick reference: Integration Services [IntegrationService], distributed events (RabbitMQ Outbox/Inbox), YARP gateway, OpenIddict, Entity Cache, database-per-service. Use when you need microservices or inter-service communication in ABP. |
ABP Framework — Microservices
ABP v10.x microservice template (Business+). Synchronous = Integration Services, asynchronous = distributed events. YARP gateway + OpenIddict auth server.
Trigger
"ABP microservices", "integration service", "inter-service communication", "distributed event", "YARP gateway", "auth server".
Structure
apps/{web,public-web,auth-server} gateways/web-gateway(YARP)
services/{administration,identity,...} etc/{docker,helm}
Services are NOT layered: a single project + *.Contracts (interface/DTO/ETO) + *.Tests. DbContext: IHasEventInbox, IHasEventOutbox.
Synchronous — Integration Service
[IntegrationService]
public interface IProductIntegrationService : IApplicationService
{ Task<List<ProductDto>> GetProductsByIdsAsync(List<Guid> ids); }
[IntegrationService]
public class ProductIntegrationService : ApplicationService, IProductIntegrationService { }
abp generate-proxy -t csharp -u http://localhost:44361 -m catalog --without-contracts
"RemoteServices": { "CatalogService": { "BaseUrl": "http://localhost:44361" } }
Use an Integration Service, not an application service. When: immediate response + data needed for the operation.
Asynchronous — Distributed Event (RabbitMQ)
[EventName("Product.StockChanged")]
public class StockCountChangedEto { public Guid ProductId { get; set; } public int NewCount { get; set; } }
await _distributedEventBus.PublishAsync(new StockCountChangedEto { ... });
public class Handler : IDistributedEventHandler<StockCountChangedEto>, ITransientDependency
{ public async Task HandleEventAsync(StockCountChangedEto e) { } }
When: state change notifications, loose coupling. Handlers must be idempotent.
Entity Cache
context.Services.AddEntityCache<Product, ProductDto, Guid>();
private readonly IEntityCache<ProductDto, Guid> _cache;
Built-in infrastructure: RabbitMQ, Redis, YARP, OpenIddict.
Best Practices
- Choose the right communication (synchronous query / asynchronous notification)
- Inter-service → Integration Service
- Share only Contracts, idempotent handlers
- Database-per-service, cache remote data
Related