Publish/Consume message based on schema (loosely coupled publisher and subscriber)

44 views
Skip to first unread message

Tomasz Hodorek

unread,
Jun 6, 2018, 3:59:41 AM6/6/18
to masstransit-discuss
Hello,

I want to create really separated Publisher and subscriber. So no shared kernel with configuration and IoC modules and no shared dll with message contracts.
My plan, is to have doubled message definition (same type name, different namespace) but with same schema. This will lead to loosely coupled applications

It's seems that I'm not able to get this idea to work. Exchanges are created, but messages landing in _skipped queue. I'm using Autofac and RabbitMQ extensions. Here is configuration for Publisher:

 builder.Register(c => Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var queueConfig = c.Resolve<FoundationFSyncQueueConfiguration>();
                var componentContext = c.Resolve<IComponentContext>();

                sbc.Message<TotalImportedMessage>(x =>
                {
                    x.SetEntityName("FoundationF:TotalImportedMessage");
                });

                var host = sbc.Host(new Uri(queueConfig.RabbitMqUri), h =>
                {
                    h.Username(queueConfig.RabbitMqLogin);
                    h.Password(queueConfig.RabbitMqPassword);
                });

            }))
            .As<IBus>()
            .As<IBusControl>()
            .SingleInstance();

FoundationF:TotalImportedMessage is used to have same exchange for different message types
Configuration for subscriber (different project, assembly for all files)

builder.RegisterConsumers(Assembly.Load("FoundationF.Application"));

            builder.Register(c => Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var queueConfig = c.Resolve<FoundationFSyncQueueConfiguration>();
                var componentContext = c.Resolve<IComponentContext>();

                sbc.Message<TotalImportedMessage>(x =>
                {
                    x.SetEntityName("FoundationF:TotalImportedMessage");
                });

                var host = sbc.Host(new Uri(queueConfig.RabbitMqUri), h =>
                {
                    h.Username(queueConfig.RabbitMqLogin);
                    h.Password(queueConfig.RabbitMqPassword);
                });

                sbc.ReceiveEndpoint(host, queueConfig.RabbitMqQueueName, e =>
                {
                    e.LoadFrom(componentContext);
                });
            }))
            .As<IBus>()
            .As<IBusControl>()
            .SingleInstance();

any ideas how to get this to work?

Chris Patterson

unread,
Jun 6, 2018, 9:00:47 AM6/6/18
to masstrans...@googlegroups.com
Namespace and class names need to match, it's a rule, and it must be followed. Or your published messages will not be consumed.

You can do what you want, but you're going to end up sharing .cs files at a minimum, I can predict the future.



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/4a303551-7f9a-446e-b4db-43297e79cda3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages