HI Scott, I had the same problem and the only way I found is to avoid using
base classes as messages for consumers as rule. In fact, I suggest to work
with abstract classes to specify similar messages content and always create
the final classes to be used as messages


On Wed, Jan 19, 2011 at 4:16 PM, Scott <scott.d...@gmail.com> wrote:

> It took me a long time to figure out what was going on when I was
> getting duplicate messages.  After I found the source if the
> duplicates, it makes sense that it behaves that way.  I just didn't
> expect that behavior and I didn't know if it was by design, or if I'm
> the first person to do this odd (or lazy) approach.
>
> The reason I ran into the issue is because I have cases where the
> message content is the same, but the "context" is different when
> putting the message on the bus.  As a result, I made a subclass, as a
> way of indicating this context, instead of writing a new class with
> the same underlying properties.
>
> Now that I understand how the implementation works, I achieved the
> same result with:
> public abstract class TestBase { [[properties]] }
>
> public class TestClass1 : TestBase
> public class TestClass2 : TestBase
>
> This way the Consumers are not consuming the base class, only the
> inheritors.
>
> Hopefully this thread serves to enlighten someone else that is going
> through the same process I did.
>
>
>
>
> On Jan 19, 1:48 pm, Matt Burton <matt.bur...@gmail.com> wrote:
> > RSB is doing polymorphic dispatch here for TestClass and TestSubClass,
> > so you could have separate handlers for both types if you wanted, and
> > since you're telling RSB that TestConsumer consumes both types it's
> > calling that consumer twice. Just change that consumer to one type or
> > the other.
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Jan 19, 2011 at 10:28 AM, Scott <scott.d...@gmail.com> wrote:
> > > I have a couple of scenarios using RSB where I want to handle a
> > > message by consuming it and determining at what time in the future I
> > > want to handle it.  I can then call bus.DelaySend(...) to handle the
> > > timing.  I love that feature!
> >
> > > The problem I encountered is when using a message which is a subclass
> > > of another message:
> >
> > > public class TestClass { public string Foo { get; set; }
> > > public class TestSubClass { }
> >
> > > If my consumer class is
> >
> > > public class TestConsumer : ConsumerOf<TestClass>,
> > > CosumerOf<TestSubClass>
> >
> > > then when a message arrives of type TestSubClass, the
> > > Consume(TestSubClass) method is called twice.
> >
> > > At least in my mind, this is not expected behavior.  Is this a bug, or
> > > just a misplaced expectation on my part?
> >
> > > Thanks.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Rhino Tools Dev" group.
> > > To post to this group, send email to rhino-tools-dev@googlegroups.com.
> > > To unsubscribe from this group, send email to
> rhino-tools-dev+unsubscr...@googlegroups.com<rhino-tools-dev%2bunsubscr...@googlegroups.com>
> .
> > > For more options, visit this group athttp://
> groups.google.com/group/rhino-tools-dev?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Rhino Tools Dev" group.
> To post to this group, send email to rhino-tools-dev@googlegroups.com.
> To unsubscribe from this group, send email to
> rhino-tools-dev+unsubscr...@googlegroups.com<rhino-tools-dev%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rhino-tools-dev?hl=en.
>
>


-- 
Fernandojosé Boiton
http://www.fboiton.com/

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

Reply via email to