sagar
sagar

Reputation: 177

MassTransit In memory setup for two different application running on same process

I have two different applications which are running on the same process by creating AppDomain for each of the two applications. The bus setup for application1 looks like this :

  builder.Register(c =>
            {
                var inMemoryTransportCache = new InMemoryTransportCache(Environment.ProcessorCount);
                var bus = Bus.Factory.CreateUsingInMemory( sbc =>
                {
                    sbc.SetTransportProvider(inMemoryTransportCache);
                });
                return bus.GetSendEndpoint(new Uri(busDestination)).Result;
            }).As<ISendEndpoint>();

The bus setup for application2 looks like this :

builder.Register(c =>
            {
                var inMemoryTransportCache = new InMemoryTransportCache(Environment.ProcessorCount);
                var bus = Bus.Factory.CreateUsingInMemory(sbc =>
                {
                    sbc.ReceiveEndpoint("TestQueue", ce =>
                    {
                        ce.LoadFrom(c);
                    });
                    sbc.SetTransportProvider(inMemoryTransportCache);
                });

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

            builder.Register(c => c.Resolve<IBusControl>().GetSendEndpoint(
                new Uri("destinationUrl")).Result)
                .As<ISendEndpoint>()
                .SingleInstance();

When i send a message from application 1 to application 2 , application 2 does not receive it.

From the masstransit documentation it looks like other than the receive end point we don't have to specify anything else when running in memory .

Am i doing something wrong in the setup? i.e does the destination url matter when running in-memory. Do i have to specify the consumers as well in application2?

Any help would be much appreciated.(Using masstransit version 3.4.1)

Upvotes: 0

Views: 1296

Answers (1)

Chris Patterson
Chris Patterson

Reputation: 33278

Separate AppDomains have separate memory space, and thus are unable to share the same transport. Thus, you can't use the InMemoryTransport for inter-AppDomain communication. Believe me, it would be awesome if you could, but you can't.

Why are you using two separate AppDomains anyway? If you can collapse it into a single domain, it will work as expected.

Upvotes: 1

Related Questions