Request/reply message data

63 views
Skip to first unread message

Chris Robison

unread,
Jul 19, 2016, 5:55:18 PM7/19/16
to masstransit-discuss
I'm trying to use the MessageData feature backed by MongoDB. I have the following configuration on the consumer service (I'm using Autofac as a container):

builder.RegisterType<GenerateReportConsumer>().AsImplementedInterfaces();
builder
.Register(context =>
{
   
DataModule.InitializeDbConnectionStrings(context);
   
return new MongoDbMessageDataRepository(new MongoUrl(DbConnectionStrings.OnlineConnectionString));
})
   
.SingleInstance()
   
.As<IMessageDataRepository>();


builder
.Register(context =>
{
   
var settings = context.Resolve<IRabbitMqConfiguration>();
   
var repository = context.Resolve<IMessageDataRepository>();
   
return Bus.Factory.CreateUsingRabbitMq(cfg =>
   
{
        cfg
.UseNLog();
        cfg
.UseMessageData<IGenerateReportResult>(repository);
        cfg
.Host(settings.BrokerUrl, hostCfg =>
       
{
            hostCfg
.Username(settings.Username);
            hostCfg
.Password(settings.Password);
            hostCfg
.UseCluster(clusterCfg =>
           
{
                clusterCfg
.ClusterMembers = settings.ClusterMembers.ToArray();
           
});
       
});


        cfg
.ReceiveEndpoint(MessagingConstants.ReportQueue, endPntCfg =>
       
{
            endPntCfg
.Consumer<IConsumer<IGenerateProjectReport>>(context);
            endPntCfg
.Consumer<IConsumer<IGenerateInstanceReport>>(context);
            endPntCfg
.Consumer<IConsumer<IGenerateInternalReport>>(context);
       
});
   
});
})
   
.SingleInstance()
   
.As<IBusControl>()
   
.As<IBus>();

And I have the following in a web application:

builder.Register(context =>
{
   
DataModule.InitializeDbConnectionStrings(context);
   
return new MongoDbMessageDataRepository(new MongoUrl(DbConnectionStrings.OnlineConnectionString));
})
   
.SingleInstance()
   
.As<IMessageDataRepository>();


builder
.Register(context =>
{
   
var settings = context.Resolve<IRabbitMqConfiguration>();
   
var repository = context.Resolve<IMessageDataRepository>();
   
var bus = Bus.Factory.CreateUsingRabbitMq(cfg =>
   
{
        cfg
.UseNLog();
        cfg
.UseMessageData<IGenerateReportResult>(repository);
        cfg
.Host(settings.BrokerUrl, hostCfg =>
       
{
            hostCfg
.Username(settings.Username);
            hostCfg
.Password(settings.Password);
            hostCfg
.UseCluster(clusterCfg =>
           
{
                clusterCfg
.ClusterMembers = settings.ClusterMembers.ToArray();
           
});
       
});
   
});
    bus
.Start();
   
return bus;
})
.SingleInstance()
.As<IBusControl>()
.As<IBus>()
.AutoActivate();


builder
.Register(context =>
{
   
var bus = context.Resolve<IBus>();
   
return new PublishRequestClient<IGenerateProjectReport, IGenerateReportResult>(bus, MessagingTimeout);
}).As<IRequestClient<IGenerateProjectReport, IGenerateReportResult>>();

The result interfaces look like the following:

public interface IGenerateReportResult : IResult
{
   
List<IGenerateReportResultPart> Parts { get; }
}

public interface IGenerateReportResultPart
{
   
string Name { get; }
   
string Extension { get; }
   
string Type { get; }
   
MessageData<byte[]> Content { get; }
}


It looks like data is being stored in Mongo just fine and the message is making it back to the client just fine. However, when I await the value on the MessageData object, I immediately get an exception saying the message data was not loaded. Any suggestions on what I'm doing wrong?

Chris Robison

unread,
Jul 19, 2016, 6:43:53 PM7/19/16
to masstransit-discuss
Looking at the LoadMessageData extension seems to be showing that it is only going one level deep into an object.

Chris Patterson

unread,
Jul 19, 2016, 6:54:36 PM7/19/16
to masstrans...@googlegroups.com
Yeah, that would explain it. I don't think it goes through the entire object graph, just the first level.


--
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-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/10ab7732-7f24-46ad-bd19-27676badce4a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages