Hi Adam
Yeah that's what I've been using actually.
Ok below is from my AR1 as it handles the incoming user command.. im trying to send IssueReferralMessage to AR2 (ReferredOpportunity)
public void IssueReferral(Guid referredOpportunityId, Guid sourceId, string sourceName, Guid managerId, string managerName, string reference, string caption, string location, string description)
{
var referral = new IssueReferralMessage
{
MessageId = Guid.NewGuid(),
SourceOpportunityId = EventSourceId,
SourceId = sourceId,
ManagerId = managerId,
Reference = reference,
Caption = caption,
Location = location,
Description = description
};
// THIS WORKS in unit testing -- but does not work when executed within a command handler
//var messagingService = NcqrsEnvironment.Get<IMessageService>();
//messagingService.Process(referral);
// THIS DOESNT WORK -- i feel this should work but the message processor doesnt fire
To().Aggregate<ReferredOpportunity>(referredOpportunityId)
.Send(referral);
}
And my ncqrs configuration is set up to use the following messaging service;
private static IMessageService InitializeMessageService()
{ var messagingService = new MessageService();
//messagingService.UseReceivingStrategy(IssueReferralMessageStrategy.ReceivingStrategy()); messagingService.UseReceivingStrategy(new ConditionalReceivingStrategy(x => true, new LocalReceivingStrategy()));
var messageSendingEventHandler = new MessageSendingEventHandler(); var sendingStrategy = new FakeSendingStrategy(messagingService); messageSendingEventHandler.UseStrategy(new ConditionalSendingStrategy(x => true, sendingStrategy)); ((InProcessEventBus)NcqrsEnvironment.Get<IEventBus>()).RegisterHandler(messageSendingEventHandler);
return messagingService;
Any thoughts?