I have a simple ConsumerDefinition:
public class HealthCheckConsumerDefinition : ConsumerDefinition<LoopbackConsumer>
{
public HealthCheckConsumerDefinition(IOptions<HealthCheckOptions> options)
{
EndpointName = options.Value.HostName;
Endpoint(configurator => configurator.Temporary = true); // not work
}
protected override void ConfigureConsumer(IReceiveEndpointConfigurator endpointConfigurator, IConsumerConfigurator<LoopbackConsumer> consumerConfigurator)
{
endpointConfigurator.ConfigureConsumeTopology = false;
base.ConfigureConsumer(endpointConfigurator, consumerConfigurator);
}
}
I expect the Temporary=true property to configure an endpoint with the AutoDelete = true and Durable = false properties, because this code is in the ApplyEndpointDefinition method of the RabbitMqHostConfiguration class: https://github.com/MassTransit/MassTransit/blob/5fb6b4e31582970b0571e9fe6ac77793a0b3242a/src/MassTransit.RabbitMqTransport/Configuration/Configuration/RabbitMqHostConfiguration.cs#L60
public void ApplyEndpointDefinition(IRabbitMqReceiveEndpointConfigurator configurator, IEndpointDefinition definition)
{
if (definition.IsTemporary)
{
configurator.AutoDelete = true;
configurator.Durable = false;
}
...
}
But in the ConfigureEndpoints method of the class, the ConsumerDefinition registry is converted to the DelegateEndpointDefinition, which does not override the IsTemporary property based on the ConsumerDefinition object passed to the constructor: https://github.com/MassTransit/MassTransit/blob/89ba77036230a15be108e8ade3a0e6fe5309a94d/src/MassTransit/Configuration/Registration/Registration.cs#L178
How to get around this problem and declare Temporary endpoint within the ConsumerDefinition?