Integration Services¶
Integration service concept is designed for request/response style inter-module (in modular applications) and inter-microservice (in distributed systems) communication. It is different from the application services that are built for inter-module (or inter-microservice) communication from the application services that are intended to be consumed from a UI or a client application.
Integrationn Service Interface¶
- Do define an
interface
for each application service in the application contracts package. - Do inherit from the
IApplicationService
interface. - Do use the
IntegrationService
postfix for the interface name (ex:IIdentityUserIntegrationService
). - Do create version folder each application service
Marking an Application Service as Integration Service¶
You can use the [IntegrationService] attribute on top of the application service class as shown below:
[IntegrationService]
public class IdentityUserIntegrationService : IdentityAppService, IIdentityUserIntegrationService
{
protected IIdentityUserRepository UserRepository { get; }
protected IdentityUserRepositoryExternalUserLookupServiceProvider UserLookupServiceProvider { get; }
public IdentityUserIntegrationService(IIdentityUserRepository userRepository,
IdentityUserRepositoryExternalUserLookupServiceProvider userLookupServiceProvider)
{
UserRepository = userRepository;
UserLookupServiceProvider = userLookupServiceProvider;
}
public async Task<UserData> FindByIdAsync(Guid id)
{
var userData = await UserLookupServiceProvider.FindByIdAsync(id);
if (userData == null)
{
return null;
}
return new UserData(userData);
}
}
If your application service has an interface, like IIdentityUserIntegrationService
in this example, you can use it on the service interface:
[IntegrationService]
public interface IIdentityUserIntegrationService : IApplicationService
{
Task<UserData> FindByIdAsync(Guid id);;
}
If you've used the [IntegrationService] on top of your service interface, it is not needed to use on the service class too.
That's all; * That service is not exposed by default, unless you explicitly set ExposeIntegrationServices options * If you are using the Auto API Controllers feature in your application, the URL prefix will be /integration-api
instead of /api
for your integration services. Thus, you can distinguish internal and external service communications and take additional actions, such as preventing REST API calls for integration services out of API Gateway. * Audit logging is disabled by default for the integration services.