Repository navigation
Unable to Intercept Envelope Headers Before RabbitMQ Transport Execution in Wolverine with InvokeAsync Operation #1873
Replies: 1 comment
|
Same issue on my side (with azure service bus, rather than rabbitmq) so the issue seems to be transport agnostic. my findings were metadatarules only works on fire and forget events. Anything with a response (invoke) does not use metadatarules. It looks like a design decision, perhaps the documentation would benefit from mentioning this limitation with metadata rules. My workaround for this was to make my own static extension method on IServiceBus which adds the common headers I need to use. Then just swap all invoke calls over to my own extension method. The next bit is a bit extra, but you can setup a roslyn analyzer to give compile errors/warnings on usage of invoke/invokefortenant and point to your extension method instead for added safety. |
Uh oh!
There was an error while loading. Please reload this page.
Hi Team,
I’m trying to capture envelope message details such as CorrelationId and also add additional information to the header (like user credentials and other metadata). However, I’m unable to achieve this. I’ve tried using middleware, IEnvelopeRule, and IRabbitMqEnvelopeMapper, but none of these seem to be triggered once InvokeAsync is called, before the execution reaches the RabbitMQ transport layer.
am using latest version 5.4.0 . Any suggestion please
Below are client side configuration tried
builder.UseWolverine(static opts =>
{
opts.Discovery
// Turn off the default handler conventions altogether
.DisableConventionalDiscovery();
});
and Middleware and IEnvlopeRule and IRabbitMqEnvelopeMapper implementionation are below
public class EnvelopeInterceptRule : IEnvelopeRule
{
}
public class EnvelopHanlingMiddleware
{
public async Task BeforeAsync(
Envelope envelope,
Func next)
{
Console.WriteLine("Entered into middleware");
await next();
}
}
public class CustomRabbitMqMapper : IRabbitMqEnvelopeMapper
{
public void MapEnvelopeToOutgoing(Envelope envelope, IBasicProperties props)
{
Console.WriteLine("MAPPER CALLED (outgoing)");
}
All reactions