Distributed **event outbox ** for MongoDB not Added records to database
I enable both inbox and outbox events and set all configuration related with them when I publish the event and received by consumer new record is added to inbox collection in database but outbox is always empty
I try to publish from application service and also from domain but both not working
this is from application service: await _priorRequestRepository.InsertAsync(new PriorRequest()); await _distributedEventBus.PublishAsync( new PriorRequestPostedEto { PriorRequestInput = input.PriorRequest, TransactionID = output.TransactionID, } );
this is from domain public PriorRequest() { AddDistributedEvent(new PriorRequestPostedEto1());
}
this is my db context: [ConnectionStringName(PriorRequestServiceDbProperties.ConnectionStringName)] public class PriorRequestServiceMongoDbContext : AbpMongoDbContext, IPriorRequestServiceMongoDbContext, IHasEventInbox, IHasEventOutbox { public IMongoCollection<IncomingEventRecord> IncomingEvents => Collection<IncomingEventRecord>(); public IMongoCollection<OutgoingEventRecord> OutgoingEvents => Collection<OutgoingEventRecord>(); public IMongoCollection<PriorRequest> PriorRequests => Collection<PriorRequest>();
protected override void CreateModel(IMongoModelBuilder modelBuilder)
{
base.CreateModel(modelBuilder);
modelBuilder.Entity<PriorRequest>(b => { b.CollectionName = PriorRequestServiceDbProperties.DbTablePrefix + "PriorRequests"; });
modelBuilder.ConfigurePriorRequestService();
modelBuilder.ConfigureEventInbox();
modelBuilder.ConfigureEventOutbox();
}
}
and this is the module configuration private void ConfigureDistributedEventBus() { Configure<AbpDistributedEventBusOptions>(options => { options.Inboxes.Configure(config => { config.UseMongoDbContext<PriorRequestServiceMongoDbContext>(); });
options.Outboxes.Configure(config =>
{
config.UseMongoDbContext<PriorRequestServiceMongoDbContext>();
});
});
}
the event is working and consumed from other service but the problem just in the outbox event not working
1 Answer(s)
-
0
Hi,
If you have configured AbpDistributedEntityEventOptions as follows, this may be the problem:
Configure<AbpDistributedEntityEventOptions>(options => { options.AutoEventSelectors.AddAll(); });
Because the line
options.AutoEventSelectors.AddAll();
causes an issue. I tested the following code instead, and it works as expected:Configure<AbpDistributedEntityEventOptions>(options => { // options.AutoEventSelectors.AddAll(); // do not use this method until next version of ABP // Use following codes for your entities options.AutoEventSelectors.Add<MyEntity1>(); options.AutoEventSelectors.Add<MyEntity2>(); });
We will address the AddAll issue in this PR: 🔧 https://github.com/abpframework/abp/pull/22471