2
public class MySaga<TRequest, TResponse> : Saga<SagaData<TRequest>>,
                                IAmStartedByMessages<TRequest>,
                                IHandleMessages<AsyncResponse>,
                                IHandleTimeouts<TimeOut>
    where TRequest : MyRequest
    where TResponse : MyResponse, new()
{}

public class SagaData<T> : IContainSagaData
{
    public Guid Id { get; set; }
    public string Originator { get; set; }
    public string OriginalMessageId { get; set; }
    public T Request { get; set; }
}

Wired it up after my validation handler in orderspecifier

public class HandlersOrderSpecifier : ISpecifyMessageHandlerOrdering
{
    public void SpecifyOrder(Order order)
    {
        order.Specify(First<ValidationHandler>.Then<MySaga<RequestType,ResponseType>>());
    }
}

Only if I remove the generic implementation details it works, else I end up in SagaNotFoundHandler.

  • How do you register your generic saga in the container? – Alexey Zimarev May 02 '15 at 09:53
  • Have a look at the HandlersOrderSpecifier class. – Gopal Singh May 02 '15 at 10:39
  • True, the generic saga is not registered in the container. Any pointers how to do that? – Gopal Singh May 03 '15 at 14:21
  • To be honest, I don't see how this should work, I am not familiar with Saga finding code. When you have a generic registration in Autofac, it will resolve it by explicit request, but it is registered implicitly. You can try building your own container with explicit registrations of possible TRequest and TResult sagas. If you're using v5, you can try implementing a custom saga finder IFindSagas. – Alexey Zimarev May 03 '15 at 14:53
  • Its intentionally so, I have gone through the NServicebus source code and in NServiceBus.Core\sagas.cs the generic type are completely ignored when scanning types for saga's. – Gopal Singh May 03 '15 at 16:33
  • @GopalSingh can you explain what you are trying to achieve. What is the purpose of this saga? Which persistence are you using etc.? – Daniel Marbach May 05 '15 at 14:54

0 Answers0