Publishing generic messages - Subscribe to specific messages

1,134 views
Skip to first unread message

Christoph

unread,
Jul 25, 2012, 8:39:30 AM7/25/12
to masstrans...@googlegroups.com
I'm currently thinking about a specific requirement and whether it is solvable with MassTransit or not.

I have a system where events could happen. I could abstract this events in terms of what happened (Create, Update, ...), on which type it happened and which record were affected.
This system has no chance to publish messages to either MassTransit or RabbitMQ directly. I would use some relay, which will do that in the name of this system. 

The messages which should be published will contain for example Event:Create/Entity:account/ID:someid Nothing more, nothing less.

Is there any concept in MassTransit which I could use to subscribe to such a general message - but only a specific type. Like a subscription should only be registered for Event:create. Everything else should not be routed to this consumer.
Something like the Topic Exchanges of RabbitMQ. 

For a better understanding. The goal is that the system publish all events to the bus. For integration tasks we would register new consumers for specific events. This should happen without adding new message classes to the system.

Any ideas? 

Dru Sellers

unread,
Jul 25, 2012, 11:15:10 AM7/25/12
to masstrans...@googlegroups.com
So MT is a 'Type' based system so lets see if we can make this happen


public class CreationEvent : LifecycleEvent
{
    public string Entity { get; set; } //account
    public string Id {get;set;} //some id
}

public class DeletionEvent : LifecycleEvent
{
    public string Entity { get; set; } //account
    public string Id {get;set;} //some id
}

public interface LifecycleEvent
{
    string Entity { get; }
    string Id { get;}
}

So now you can subscribe to just Creation or Deletion events.


does that answer your question?

-d



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/xqaB3OSj4yIJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Christoph

unread,
Jul 25, 2012, 11:36:55 AM7/25/12
to masstrans...@googlegroups.com
So now you can subscribe to just Creation or Deletion events.

does that answer your question?

Not yet ;) 
I try to continue with your example. It would be ok for me to define types for all specific events.
The problem is that I would subscribe for CreationEvent only for the entity account - without having to define a special type for this. All other CreationEvents should be not subscribed.

With only RabbitMQ I would publish a message with create.account and the id as the body. If I am interested in all events specific to account, I would create a binding with *.account as routing key.

Dru Sellers

unread,
Jul 25, 2012, 11:39:22 AM7/25/12
to masstrans...@googlegroups.com
correct, but rabbitmq routing is not exposed by MT. MT uses a 'Type' based routing. 

so if you want to restrict the routing you must do so by 'Type' in some cases this can be a hinderance, but in most cases (at least our cases) its a strong benefit.

-d

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.

Dru Sellers

unread,
Jul 25, 2012, 11:40:05 AM7/25/12
to masstrans...@googlegroups.com
you can always filter it out at the consumer, RabbitMQ can push a crap ton of traffic on even modest hardware

-d

Christoph

unread,
Jul 26, 2012, 4:24:32 AM7/26/12
to masstrans...@googlegroups.com
I had thought about this, but was looking for a 'cleaner' solution. I try this approach and take a look at how it will work out.
Thx.

Dru Sellers

unread,
Jul 26, 2012, 12:42:19 PM7/26/12
to masstrans...@googlegroups.com
I don't really advise this, but you could try

public class CreationEvent : LifecycleEvent<TEntity>
{
    public string Id {get;set;} //some id
}

public class DeletionEvent : LifecycleEvent<TEntity>
{
    public string Id {get;set;} //some id
}

public interface LifecycleEvent<TEntity>
{
    string Id { get;}
}


On Thu, Jul 26, 2012 at 3:24 AM, Christoph <lang...@gmail.com> wrote:
I had thought about this, but was looking for a 'cleaner' solution. I try this approach and take a look at how it will work out.
Thx.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages