My Exception Message are trap, but the exception is publish to my other Queue

70 views
Skip to first unread message

Andre Leblanc

unread,
Oct 26, 2016, 3:22:09 PM10/26/16
to masstransit-discuss
Goog day,


This is how I start my bus,


BusControl = Bus.Factory.CreateUsingRabbitMq(x =>

{

host = x.Host(new Uri(rabbihost), h =>

{

   h.Username(User);

   h.Password(pwd);

});


  var endPointName = ConfigurationManager.AppSettings["EndPointName"];

  x.ReceiveEndpoint(host, endPointName, e =>

  {


          e.UseRetry(Retry.Interval(4, 750));

          OnRegisterConsumer(e);

          e.Consumer<LMSQFaultMessageConsumer>();


    });

});



The endPointName are the Name my Window Service listen to the Queue.


I have 3 window service start, all on there own Queue

Queue1, Queue2, Queue2


I publish 1 message, An I can see it In RabbitMQ in the 3 Queues.


When I Start My service for Queue1, I received the error message by email from LMSQFaultMessageConsumer.


Then in RabbitMQ I see 1 more message in Queue2 and Queue3, the new message is the Exception from Queue1.



How can my Consumer can publish a fault error in my other Queue ?


Thanks a lot!

André








Andre Leblanc

unread,
Oct 27, 2016, 3:47:49 PM10/27/16
to masstransit-discuss
From the documentation:

"In addition to moving the message to an error queue, MassTransit also generates a Fault<T> event. If the received message specified a FaultAddress header, the fault is sent to that address. If a fault address is not found, and a ResponseAddress is present, the fault is sent to the response address. If neither address is present, the fault is published."

Where can I connect or observe this behavior. so I can change the address so the fault is not publish....  

I think it's with middeleware ... Any Sample I can Check... I'm not sure I understand the logger exception present here http://masstransittemp.readthedocs.io/en/latest/middleware/custom.html


Thanks a lot!
André

Chris Patterson

unread,
Oct 27, 2016, 4:12:28 PM10/27/16
to masstrans...@googlegroups.com
Can you explain what you are trying to do, versus asking how to do the specific thing you are asking?

For instance, are you trying to handle the consumer exception in a different way than the default behavior?


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/0d2748b6-19d5-4a36-ad48-404c2d907a38%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Andre Leblanc

unread,
Oct 28, 2016, 7:55:32 AM10/28/16
to masstransit-discuss
I replicate information across many databases, from one main database.
A user create a new message, then publish it to 9 instances waiting (Window Service.)

In the Windows Services I have 2 Consumers one for my IEnvelope and one for my Fault<IEnvelope>
The consumer for Fault<IEnvelope> send email alert.

When a error occur on 1 instance, the problem I have is the 8 others instances waiting, receive the message Fault<IEnvelope>. I wan't to avoid that. So I don't need to filter message on the other 8 instances.
To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
Oct 28, 2016, 12:18:46 PM10/28/16
to masstrans...@googlegroups.com
Well, when you send your command, you can specify a FaultAddress on the SendContext, and that will directly send the fault to that address rather than publish it. Which should give you what you need.

To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Andre Leblanc

unread,
Oct 28, 2016, 1:24:13 PM10/28/16
to masstransit-discuss
OK, but in my Window Service for a specific database, where the error occur, I only have two Consumer. 
Where/how can I modify the SendContext of a consumer ?

Thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
Oct 28, 2016, 1:45:29 PM10/28/16
to masstrans...@googlegroups.com
await endpoint.Send(new MyCommand(), context => context.FaultAddress = ...);

To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Andre Leblanc

unread,
Oct 28, 2016, 2:20:08 PM10/28/16
to masstransit-discuss
Sorry I'm a begginer with MassTransit... But I put that line where ?
In my Fault Consumer or my normal Consumer ?

Nothing is define to Send Something?

When I start my bus I have:
        public void CreateBus()
        {
            BusControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                host = cfg.Host(new Uri(Rabbithost), h =>
                {
                    h.Username(User);
                    h.Password(pwd);
                });

                cfg.ReceiveEndpoint(host, EndPointName, e =>
                {
                    e.UseRetry(Retry.Interval(4, 750)); // 
                    e.Consumer<LMSQEnvelopeConsumer>();
                    e.Consumer<LMSQFaultMessageConsumer>();
                });
            });
        }

        private void OnRegisterConsumer(IRabbitMqReceiveEndpointConfigurator e)
        {
            RegisterConsumer?.Invoke(null, e);
        }


To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
Oct 28, 2016, 3:52:36 PM10/28/16
to masstrans...@googlegroups.com
Where are you actually sending the LMSQEnvelope message? That is where you want to add the FaultAddress.

To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Andre Leblanc

unread,
Oct 28, 2016, 4:52:16 PM10/28/16
to masstransit-discuss
My message is sent from a single place. But receive in many place.

I have 9 receivers. So when I sent my LMSQEnvelope I don't know what receiving Queue will fail so I don't know what FaultAdress to give.

I'm sure I miss something basic.

Andre Leblanc

unread,
Nov 1, 2016, 1:01:17 PM11/1/16
to masstransit-discuss
For now I add this in my Fault Consumer...
    public class LMSQFaultMessageConsumer : IConsumer<Fault<IEnvelope>>
    {
        public Task Consume(ConsumeContext<Fault<IEnvelope>> context)
        {

            return Task.Run(() =>
            {

                // Source address must be the same has you are. To Send the Error.
                // When an exception is catch it is republish to all because our other service listen for the same message.
                // So if we do not do this validation, all other service will also publish again the error.
                if (context.SourceAddress.AbsolutePath.Contains(ClientLMSQ.EndPointName))
                {
                    SendEmailNotificationFault(context);
                }
            });
        }

        protected virtual void SendEmailNotificationFault(ConsumeContext<Fault<IEnvelope>> context)
        {
             ......
        }
    }
}
Reply all
Reply to author
Forward
0 new messages