Re: [rhino-tools-dev] Saga and DelaySend

69 views
Skip to first unread message

Corey Kaylor

unread,
Jul 10, 2012, 10:43:33 AM7/10/12
to rhino-t...@googlegroups.com
Which container? How are the consumers getting registered? Test code? Your sample *should* work fine so the problem is likely with the container or test code.

On Tue, Jul 10, 2012 at 8:20 AM, Ivica Munitic <imun...@gmail.com> wrote:
Hello, I have a saga like this

    public class MySaga
        : ISaga<MySagaState>,
        InitiatedBy<Start>,
        Orchestrates<Timeout>
    {
        readonly IServiceBus _bus;

        public MySagaState State { get; set; }

        public Guid Id { get; set; }
        public bool IsCompleted { get; set; }

        public MySaga(IServiceBus bus)
        {
            _bus = bus;
            this.State = new MySagaState();
        }

        public void Consume(Start message)
        {
            State.ActivityId = message.ActivityId;
            _bus.DelaySendToSelf(DateTime.Now.AddSeconds(10), new Timeout() { CorrelationId = this.Id });

        }

        public void Consume(Timeout message)
        {
            _bus.Publish(new Expired() { ActivityId = State.ActivityId });

            IsCompleted = true;
        }
    }

The problem I'm having is that the saga never consumes the Timeout message.
the timeout message finishes in the discarded subqueue.
The logs says that it did not get processed because there were no cosumers for it.

I'm really confused.

P.S.

I'm using an InMemorySagaPersister to test this saga.



--
You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rhino-tools-dev/-/ZXvSpUGLfIMJ.
To post to this group, send email to rhino-t...@googlegroups.com.
To unsubscribe from this group, send email to rhino-tools-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en.

Ivica Munitic

unread,
Jul 10, 2012, 10:58:01 AM7/10/12
to rhino-t...@googlegroups.com
Sorry for the email, I clicked the wrong button somewhere :)

Here is the BootStrapper:

    public class BootStrapper : AutofacBootStrapper
    {
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();

            var builder = new ContainerBuilder();
            builder.RegisterGeneric(typeof(InMemorySagaPersister<>)).As(typeof(ISagaPersister<>));
            builder.Update(Container);
        }

        protected override void OnBeginStart()
        {
            base.OnBeginStart();

            XmlConfigurator.Configure();
        }
    }

and here is the configuration of the bus

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="rhino.esb" type="Rhino.ServiceBus.Config.BusConfigurationSection, Rhino.ServiceBus"/>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>

  <rhino.esb>
    <bus threadCount="1" numberOfRetries="5" endpoint="msmq://localhost/rsb-retention" transactional="false" />
    <messages>
      <add name="MyNamespace.Timeout" endpoint="msmq://localhost/rsb-retention" transactional="false" />
    </messages>
  </rhino.esb>

  <log4net>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level [%ndc] - %message%newline"/>
      </layout>
    </appender>
    <root>
      <level value="DEBUG"/>
      <appender-ref ref="ConsoleAppender"/>
    </root>
  </log4net>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Rhino.Queues" publicKeyToken="0b3305902db7183f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.4.1.0" newVersion="1.4.2.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>


The assembly binding is because Rhino.ServiceBus.Host.exe works with Rhino.Qieies 1.4.1.0 :)

Regards, Ivica
To post to this group, send email to rhino-tools-dev@googlegroups.com.
To unsubscribe from this group, send email to rhino-tools-dev+unsubscribe@googlegroups.com.

Ivica Munitic

unread,
Jul 10, 2012, 11:03:38 AM7/10/12
to rhino-t...@googlegroups.com
Here is also the test console application

    class Program
    {
        static void Main(string[] args)
        {
            var host = new DefaultHost();
            host.Start<BootStrapper>();

            string line;
            while ((line = Console.ReadLine().ToLower()) != "q")
            {
                int n;
                if (int.TryParse(line, out n))
                {
                    (host.Bus as IServiceBus).Send(new Start() { ActivityId = n, CorrelationId = Guid.NewGuid() });
                }
            }
        }
    }

    class BootStrapper : AutofacBootStrapper { }

and its configuration

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="rhino.esb" type="Rhino.ServiceBus.Config.BusConfigurationSection, Rhino.ServiceBus" />
  </configSections>
  <rhino.esb>
    <bus threadCount="1"
            numberOfRetries="5"
            endpoint="msmq://localhost/rsb-retention.client" />
    <messages>
      <add name="MyNamespace.Start" endpoint="msmq://localhost/rsb-retention" transactional="false" />
    </messages>
  </rhino.esb>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Rhino.Queues" publicKeyToken="0b3305902db7183f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
</configuration>

Scott

unread,
Jul 10, 2012, 11:04:24 AM7/10/12
to rhino-t...@googlegroups.com
I've had this problem with sagas in the past. Usually the resolution is to make sure your Timeout message actually implements the ISagaMessage interface, instead of just having a CorrelationId property in the class.

It's an easy mistake to make, and I've done it more than once.

Ivica Munitic

unread,
Jul 10, 2012, 11:06:47 AM7/10/12
to rhino-t...@googlegroups.com
Both Start and Timeout actually do implement ISagaMessage

Corey Kaylor

unread,
Jul 10, 2012, 11:08:19 AM7/10/12
to rhino-t...@googlegroups.com
Try in your test code to resolve an instance of Orchestrates<Timeout>. If it doesn't resolve it could be a bug in the Autofac container.

To view this discussion on the web visit https://groups.google.com/d/msg/rhino-tools-dev/-/ibB9qIxFOm8J.

To post to this group, send email to rhino-t...@googlegroups.com.
To unsubscribe from this group, send email to rhino-tools-d...@googlegroups.com.

Ivica Munitic

unread,
Jul 10, 2012, 11:13:27 AM7/10/12
to rhino-t...@googlegroups.com
I've put this in ConfigureContainer in the BootStrapper (of the saga)

var o = Container.Resolve<Orchestrates<Timeout>>();

and got this exception when i run it.

The requested service 'Rhino.ServiceBus.Sagas.Orchestrates`1[[MyNamespace.Timeout, MyNamespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

Ivica Munitic

unread,
Jul 10, 2012, 11:18:44 AM7/10/12
to rhino-t...@googlegroups.com
Ok changed to Windsor and now all works :)

So it is a bug somewere :)

Tnx for your help Corey and Scott

Regards, Ivica

Corey Kaylor

unread,
Jul 10, 2012, 11:17:30 AM7/10/12
to rhino-t...@googlegroups.com
There is likely a bug right around here then.



To view this discussion on the web visit https://groups.google.com/d/msg/rhino-tools-dev/-/vfvD42DANkMJ.

To post to this group, send email to rhino-t...@googlegroups.com.
To unsubscribe from this group, send email to rhino-tools-d...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages