Saga Orchestrate consumer not being found

28 views
Skip to first unread message

Dan Ling

unread,
Apr 29, 2013, 5:48:34 PM4/29/13
to rhino-t...@googlegroups.com
I'm trying to get an extremely simple saga to work.  My saga is successfully initiated by "DinnerCooked", but when I send it a "DinnerServed" message,  I'm getting a "message received but no consumer found" error.

Here is my code:



    public class DinnerSaga : ISaga<DinnerState>,
                              InitiatedBy<DinnerCooked>,
                              Orchestrates<DinnerServed>
    {
        public Guid Id { get; set; }
        public bool IsCompleted { get; set; }
        public DinnerState State { get; set; }

        public void Consume(DinnerCooked message)
        {
            Console.WriteLine("Chef cooked a {0}.", message.Dish);
            IsCompleted = false;
        }

        public void Consume(DinnerServed message)
        {
            Console.WriteLine("Dinner has been served, yum.");
            IsCompleted = true;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Chef is ready to cook.");

            var host = new DefaultHost();
            host.Start<ChefBootStrapper>();

            Console.WriteLine("Press enter to begin cooking dinner.");
            Console.ReadLine();

            IServiceBus bus = host.Bus as IServiceBus;
            bus.Send(new DinnerCooked { Dish = "steak"});

            Console.WriteLine("Chef cooked a steak.");
            Console.WriteLine("Press enter to serve dinner to the customer.");
            Console.ReadLine();
            bus.Send(new DinnerServed {Dish = "steak"});

            Console.ReadLine();
        }
    }

    public class ServerBootStrapper : UnityBootStrapper
    {
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();
            Container.RegisterType<ISagaPersister<DinnerSaga>, InMemorySagaPersister<DinnerSaga>>();
            //Container.RegisterType<Orchestrates<DinnerServed>, ConsumerOf<DinnerServed>>();
        }
    }

Corey Kaylor

unread,
Apr 29, 2013, 6:33:14 PM4/29/13
to Rhino Tools Dev
If you're storing the state in memory and you get a new instance of ISagaPersister each time (i.e. not a singleton) then you would effectively have no persistence.


--
You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rhino-tools-d...@googlegroups.com.
To post to this group, send email to rhino-t...@googlegroups.com.
Visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dan Ling

unread,
Apr 30, 2013, 10:14:31 AM4/30/13
to rhino-t...@googlegroups.com
Thanks Corey.... so now I tried registering the InMemorySagaPersister as a singleton, but I'm still getting the same error.  Is there anything else I need to do?  I'm not managing a saga guid or anything, I'm not sure if that's required.

    public class ServerBootStrapper : UnityBootStrapper
    {
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();
            Container.RegisterType<ISagaPersister<DinnerSaga>, InMemorySagaPersister<DinnerSaga>>(new ContainerControlledLifetimeManager());

Dan Ling

unread,
May 1, 2013, 11:07:36 AM5/1/13
to rhino-t...@googlegroups.com
I finally got this to work once I realized that the GUID must be generated and maintained by the initiator of the saga, and that the messages need to inherit ISagaMessage.  I initially thought the saga was doing all that work magically, behind the scenes.

Dan Ling

unread,
May 1, 2013, 12:18:39 PM5/1/13
to rhino-t...@googlegroups.com
On that note, is there any reason why the generic parameter for InitiatedBy and Orchestrates isn't constrained to ISagaMessage?
Reply all
Reply to author
Forward
0 new messages