Both classes and interfaces are supported. The list of message types is carried in message metadata, so it is always available
However, your consumer explicitly consumes the base interface, so the consume context get exactly that type deserialised. This is because MT does not know what type it is since there is more than one, so it deserialises to the one you can consume.
If you need to get another payload, you can always use
var anotherMessage = context.GetPayload<AnotherMessage>();
if you know that you received AnotherMessage
On Thursday, June 15, 2017 at 4:45:14 PM UTC+2, Tim Cools wrote:
I have a request/response situation and I need to support different return contracts. I first tried anticancer of a value object in the response:
class SomeResponse
{
public Product { get;set; }
}
class Product { ... }
class Product1 : Product { ... }
class Product2 : Product { ... }
But this is not supported by masstransit so I tried to return different response interfaces as that should be supported:
consumer:
public Task Consume(ConsumeContext<SomeRequest> request)
{
context.Respond<IProduct1Response>(new IProduct1Response( ... ));
}
interface IProductResponse { ... }
interface IProduct1Response : IProductResponse { ... }
interface IProduct2Response : IProductResponse { ... }
When I create and call a IRequestClient like this
IRequestClient<SomeRequest, IProductResponse> client = ...
var response = client.Request(new SomeResponse());
The response is always of type
IProductResponse and not of the more specific interface.
So my question is: Is returning different data sets somehow support with the request/response?