Closed Sarmaad closed 7 years ago
Hello @Sarmaad - thanks for reporting this 👍
There are currently no custom way to consume messages from the error exchange, the easiest thing is to use the fluent configuration builder to create a queue that is bound to the error exchange (with the correct routing key). See code below
await subscriber.SubscribeAsync<BasicMessage, IBasicProperties>(async (msg, props) =>
{
var host = Encoding.UTF8.GetString((byte[]) props.Headers[PropertyHeaders.Host]);
var exceptionType = Encoding.UTF8.GetString((byte[]) props.Headers[PropertyHeaders.ExceptionType]);
var stacktrace = Encoding.UTF8.GetString((byte[]) props.Headers[PropertyHeaders.ExceptionStackTrace]);
}, ctx => ctx
.UseMessageContext(c => c.GetBasicProperties())
.UseConsumerConfiguration(cfg => cfg
.FromDeclaredQueue(q => q.WithName("custom_error_queue"))
.OnDeclaredExchange(e => e.WithName("default_error_exchange"))
));
A few things:
UseMessageContext
is a extension method found in RawRabbit.Enrichers.MessageContext.Subscribe
. Basically it allows you to select any object from the IPipeContext
and pass it as an "message context". This is done so that the the exception headers (PropertyHeaders.ExceptionType
etc) can be extracted. This is only necessary if you want to extract stack trace in your handling of messages in the error queue.UseConsumerConfiguration
is an extension method that allows you to declare queue and exchange to consume from. You can also specify a routing key, if you don't the default one (from the registered INamingConvention
will be used.As for the exception: let me investigate and get back to you!
Hello again, I was able to reproduce the behavior with the un-acked messaged and has also created a fix for it. This will be part of the beta9 of the client.
Hi,
I have started using RawRabbit 2.0 Beta 8 and taking it for a spin though a message life-cycles.
The use-case I have is a subscriber to a message:
The exception is captured and a default error exchange is created, then a message is published with the error details in the headers.. which is great.
Logs:
Thank you.