0
votes

We have a system built using WCF and we are in the process of converting it to use Mass Transit and RabbitMQ.

Because it is/was a WCF service its quite RESTful in the way it operates, there are no states or sessions.

With this in mind, moving to Mass Tranist thus requires a huge amount of boiler plate code. For example we have possibly 100 WCF calls. For each one I would have to implement a separate Request/Response pair that, aside from the name, would be no different to each other. Apparently I cannot even use inheritance to abstract away the CorrelatedBy<Guid> syntax.

Is there any way I can reduce the amount of boilerplate code required to do this?

My current MassTransit code looks like this:

sbc.Subscribe(subConfig =>
{
    subConfig.Handler<CanAllocateLicensedDeviceRequest>((ctx, req) =>
    {
        bool result = this.licenceActions.CanAllocateLicensedDevice();

        ctx.Respond<CanAllocateLicensedDeviceResponse>(new CanAllocateLicensedDeviceResponse() { Result = result });
    });
}

I understand the need to have the request typed, but could I not have a generic "bool" return type that I respond with. Would the Guid not ensure it got to the right place?

1

1 Answers

0
votes

You could use a single response type to avoid creating an "ok" response type for each request/response pairing.

You also do not need to use CorrelatedBy as the RequestId is automatically set for you on the SendRequest call from the client-end of the request/response conversation.