Lykke.Cqrs.MessageCancellation is a plugin for Lykke services that use Lykke.Cqrs libriary. It consists of:
- Asp.Net Core Controller
- Command/Events Interceptors For Lykke.Cqrs
- Internal Services
- Install nuget Lykke.Cqrs.MessageCancellation
- The endpoint for controller is "/api/plugin/message-cancellation". Ensure that this route is not yet registered in your application.
- Register Cqrs Message Cancellation
var builder = new ContainerBuilder();
builder.RegisterCqrsMessageCancellation((options) =>
{
options.Value
.MapMessageId<MessageWithSomeId>(x => x.MessageId)
.MapMessageId<MessageWithGuidId>(x => x.OperationId.ToString());
});
- Add Command/Event interceptors in cqrs pipeline
protected virtual IRegistration[] GetInterceptors()
{
return new IRegistration[]
{
Register.CommandInterceptor<MessageCancellationCommandInterceptor>(),
Register.EventInterceptor<MessageCancellationEventInterceptor>()
};
}
var interceptors = GetInterceptors();
if (interceptors != null)
{
registration.AddRange(interceptors);
}
var cqrsEngine = new CqrsEngine(
logFactory,
new AutofacDependencyResolver(ctx.Resolve<IComponentContext>()),
messagingEngine,
new DefaultEndpointProvider(),
true,
registration.ToArray());