I created a custom component for a proprietary service. If this service is down i get noticed via a call of a callback function. I am throwing a custom exception at this point.
Sending exchanges to the producer/ consumer will yield no errors or exceptions (all seems to fine).
So i need to implement an emergency stop if my custom exception is thrown. I read a bit about exception handling in camel. I think i need a context-scoped onException(MyException.class).??? but what then?
Is this working on exceptions that are called without relation to an exchange? If this is working how to handle it. I want to stop certain routes in this case.
here you can find to stop routes from a route: http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html.
If you do the call of the proprietary service in a route you do have an exchange btw.
kind regards,
soilworker
I created a little workaround: I set a boolean i the callback method is called. On each call of process i check this boolean and if true i throw an exception.
With this the exception is within normal camel exception handling and onException could be used.
Related
It seems catching System.ServiceModel.EndpointNotFoundException doesn't work in orchestrations despite of:
port settings: Delivery Notification = Transmitted (it should work without this in two-way port)
catching exception in specific order
catching Microsoft.XLANGs.BaseTypes.DeliveryFailureException
catching super class exception CommunicationObjectFaultedException like here
scope in scope configuration like here
Orchestration only catches System.Exception. Is that bug or am I missing something?
EDIT :
My configuration:
Sendport WCF-WebHttp
Endpoint REST
I managed to put Microsoft.XLANGs.Core.XlangSoapException catch type by editing odx file in notepad (its hack!)- and This actually works as I want becasue
this type encapsulates System.ServiceModel.EndpointNotFoundException by Biztalk I persume.
This type of exception is thrown in orchesration but VS doesnt let me choose this type of exception I believe that is done in purpose to not to do that.
i have a custom ExceptionFilterAttribute in place that almost logs anything that gets thrown in a controller. Almost means that there are circumstances where this filter does not handle exceptions. This is where there is now a custom service that implements the IExceptionLogger interface that handles everything. This is where it gets messy.
Both handle the exception creating duplicate logs. The Attribute is prefered since it contains more custom information (dependency injected).
Is there any built in way to mark the exception as handled in order to avoid the service if the filter is used?
Is there any other way to catch only the exceptions that the filter did not handle?
I have a problem in catching the exceptions in my spring integration application.
Flow of operations in my application.
Http:inbound gateway which receives the request (error-channel defined to my custom error channel)
Service Activator for basic validations (Exceptions which are thrown from here are handled by error-channel defined on the GW)
splitter
Aggregator
Exceptions on my splitter or Aggregator are not handled by my error channel. why?
Steps taken:
I added a chain and included a header enricher and specified an error channel just before the splitter.
After this, any exception on my splitter is handled by my error channel mentioned in the header enricher.
<chain input-channel="invitations">
<header-enricher>
<error-channel ref="failed-invitations" />
</header-enricher>
<int:splitter ref="payloadSplitter" />
</chain>
But the same doesnt work when do the same on my Aggregator. why?
Whenever there is an exception in my code, it retries and gets executed more than one time. why?
I have a "errorChannel" defined which logs the exceptions. it doesnt work.
I know the thread is too old, but I was also facing a similar issue and found I declared error-channel in header-enricher but not provide 'overwrite="true"' as a parameter. And after providing 'overwrite="true"'it is working as needed. I am surprised why spring integration does not provide an overwrite=true by default.
Let us know this is what solution you did in your old code? So everyone can find out the solution for such a scenario.
I am wondering how I can tell camel to redeliver my message based on business logic.
My route is calling a soap endpoint and, depending on the message returned by the server I need to schedule a retry in a few seconds.
Basically, I have this kind of error handling configured :
onException(Throwable.class)
.handled(true)
.processRef("exceptionHandler")
.redeliveryDelay(5000)
.maximumRedeliveries(1)
.to("file://
My exceptionHandler check if the exception is a SOAP Fault, unmarshal it and depending on the content I need to schedule the retry.
Is there anyway of doing that within camel ?
Well, in the end, here is my solution :
from("...")
.doTry()
.to("...")
.doCatch(Exception.class)
.beanRef("handleException")
.end()
.beanRef("handleRegularResponse");
The processor handleException handles the exception, try to understand the issue and then throw a more precise exception. In my case, it can throw 2 types of exception : FunctionalException that do not need to redeliver, and a TechnicalException that I will try to redeliver in a few minutes.
I just have then to declare an error handler for this specific exception :
onException(TechnicalException.class)
.handled(true)
.redeliveryPolicyRef("...")
.useOriginalMessage();
HIH
We are developing a proxy in WCF that will serve as a means of communication for some handhelds running our custom client application. I am curious what error handling strategies people use as I would rather not wrap EVERY proxy call in try/catch.
When I develop ASP .NET I dont catch the majority of exceptions, I leverage Application_Error in Global asax which can then log the exception, send an email, and redirect the user to a custom error landing page. What I am looking for in WCF is similar to this, except that it would allow me to pass a general faultreason to the client from a central location.
Basically I am curious how people centralize their exception handling in WCF apps.
Thanks
You might find the IErrorHandler interface useful here. We've been using this to do pretty much what you mention - centralised exception logging and providing generalised fault reasons without having to litter the code with numerous try/catches to try and deal with the problem locally.
So here is what I did. We have a few custom exceptions in our application such as BusinessRuleException and ProcessException, WCF supports both FaultException and FaultException<T>.
General practice seems to be that you always throw FaultException to the client in the case of a general error or an error that you dont want to display exactly what happened. In other cases you can pass FaultException<T> where T is a class with information about the particular exception.
I created this concept of Violations in the application, which basically meant that any custom exception had a property containing the corresponding Violation instance. This instance was then passed down to the client enabling the client to recognize when a recoverable error had occured.
This solved part of the problem, but I still wanted a general catch all that would allow me to centeralize logging. I found this by using the IErrorHandle interface and adding my own custom error handler to WCF. Here is the code:
public class ServiceHostGeneralErrorHandler : IErrorHandler
{
public void ProvideFault(Exception ex, MessageVersion version, ref Message fault)
{
if (ex is FaultException)
return;
// a general message to the client
var faultException = new FaultException("A General Error Occured");
MessageFault messageFault = faultException.CreateMessageFault();
fault = Message.CreateMessage(version, messageFault, null);
}
public bool HandleError(Exception ex)
{
// log the exception
// mark as handled
return true;
}
}
Using this method, I can convert the exception from whatever it is to something that can be easily displayed on the client while at the same time logging the real exception for the IT staff to see. So far this approach is working quite well and follows the same structure as other modules in the application.
We use the Exception Handling Application block and shield most faults from clients to avoid disclosing sensitive information, this article might be a good starting point for you, as with "best practices" - you should use what fits your domain.