Here is my a rough example on how I would approach the problem. The OrderService just provides a simple facade to publish the orders.
class OrderService: IOrderService{
readonly IProcessBus _retlangContext;
OrderService(IProcessBus retlangContext){ _retlangContext = retlangContext;}
void SubmitOrder(IOrder order){
_retlangContext.Publish("new.order", order);
}
}
Workflows take care of receiving the message, calling the service, and routing the result. I implemented the validation workflow, but the others would be similar.
class OrderValidationWorkflow{
readonly IOrderValidationService _validator;
OrderValidationWorkflow(IOrderValidationService validator, IProcessBus retlangBus){
_validator = validator;
retlangBus.Subscribe<IOrder>("new.order", OnOrder);
}
void OnOrder(IMessageHeader header, IOrder order){
if(_validator.Validate(order))
_retlangContext.Publish("valid.order", order);
else
_retlangContext.Publish("invalid.order", order);
}
}
At runtime, I'd recommend using a dependency injection container such
as Spring.NET or Windsor for wiring together the dependencies.
Let me know if this helps at all.
Mike Rettig
Retlang Developer