Hi,
sorry for the late reply.
You were right. Regarding the very same correlation question:
Continuing my journey and now I'm trying to make sagas concurrent, moreover, planning to have multiple processes consuming same saga endpoints. At the moment testing with a single saga process. Using the latest MT, Azure ServiceBus and MT's EF extension for saga persistence.
Shopping cart example is failing for me if receive endpoint configuration has concurrency setting > 1. I tried adding exponential retry policy, it helped a bit, but still, many were failing. I thought ok, UserName value is the same maybe that's the problem, let me try and pass a guid value instead. So passed a random guid in the UserName property for the ICartItemAdded. Saga's event handler remained the same:
x.CorrelateBy(cart => cart.UserName, context => context.Message.UserName).SelectId(context => NewId.NextGuid());
then I added x.InsertOnInitial = true
created 30 messages and ran the service, but it was still failing for some messages:
Value cannot be null. Parameter name: connection.
Stacktrace:
at System.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName)
at System.Data.Entity.Infrastructure.Interception.DbTransactionInterceptionContext.WithConnection(DbConnection connection)
at System.Data.Entity.Infrastructure.Interception.DbTransactionDispatcher.Rollback(DbTransaction transaction, DbInterceptionContext interceptionContext)
at System.Data.Entity.Core.EntityClient.EntityTransaction.Rollback()
Then I commented out retry policy and changed saga's event handler to
x.CorrelateById(context => Guid.Parse( context.Message.UserName));
and that helped.
Saga endpoint config:
cfg.ReceiveEndpoint(
host,
"shopping_cart_state",
e =>
{
e.PrefetchCount = 50;
//e.UseConcurrencyLimit( 30 );
e.MaxConcurrentCalls = 30;
e.StateMachineSaga( _machine, _repository.Value );
} );
Now I'm a bit lost. I'm passing a unique guid in UserName property, so it has to be something related to establishing the correlation, the syntax, why the original one is failing then, hmm. Any help is welcome :)
Also, is there a difference between:
e.UseConcurrencyLimit( 30 ); and e.MaxConcurrentCalls = 30;
I might be wrong, but it feels like latter makes the processing a bit faster (I'm writing into files for every event in the saga, latter seems to generate the output faster)
Moreover, is there a good recommendation for PrefetchCount and UseConcurrencyLimit( ) and/or e.MaxConcurrentCalls values? Some rule like PrefetchCount is recommended to be twice the value of UseConcurrencyLimit( ) and/or e.MaxConcurrentCalls or something like that?
Thank you!