9 Replies Latest reply on Jun 17, 2013 7:41 AM by kcbabo

    How SY handles RuntimeCamelException?

    herkules

      Hi,

       

      Camel has thrown GenericFileOperationFailedException but I cannot find anything in the log file about it. I am using SY 0.0.

       

      Thanks, Jan

        • 1. Re: How SY handles RuntimeCamelException?
          dward

          Which version? You typed "SY 0.0."

          • 2. Re: How SY handles RuntimeCamelException?
            herkules

            That explains why the exceptions wanishes :-)

             

            SY 0.8.

            • 3. Re: How SY handles RuntimeCamelException?
              herkules

              Tried to debug Camel and SY. When exception is thrown from GenericFileProducer, it is stored in camel's Exchange.setException(). It seems that returned Exchange is ignored in org.switchyard.component.camel.common.handler.OutboundHandler.handleInOnly(Exchange) and exception vanishes. Is this bug in SY or do I need to add something to switchyard.xml to handle them?

               

              Thanks, jan

              • 4. Re: How SY handles RuntimeCamelException?
                kcbabo

                This is a bug w/r/t logging in 0.8 where the exception is actually logged at DEBUG level, which makes it invisible with the default logging configuration.  This has been fixed in 1.0.

                • 5. Re: How SY handles RuntimeCamelException?
                  herkules

                  I don't see any exception logged even with DEBUG level. I also tried to use camel onException or doTry/doCatch in RouteBuilder but I also don't see anything logged:

                   

                   

                  onException(GenericFileOperationFailedException.class).log("XXXXXXXXX");

                   

                  from("switchyard://Message2File"). // read message from JMS

                          doTry().

                              to("switchyard://Message2FileReference"). // store as file, this throws because file already exists on FS

                          doCatch(RuntimeException.class).

                              log("!!!!!!!!!!!!!").

                          end();

                   

                  Does https://community.jboss.org/message/777021 also apply to SY 0.8 as my interface returns nothing?

                   

                  public interface Message2File {

                      public void process(String payload);

                  }

                   

                  Thank you, Jan

                  • 6. Re: How SY handles RuntimeCamelException?
                    kcbabo

                    The exception will not be propagated back to the camel route with an inonly MEP, so I wouldn't expect the try/catch above to work in that situation.

                     

                    I would expect the DEBUG log to happen however.  Just to confirm, you set the log level for org.switchyard to DEBUG and updated the CONSOLE handler to print DEBUG as well?

                     

                    This is something that has been bugging me for a while.  Lukasz and I discussed a potential solution about a month back.  I think we can make this a bit more intuitive for 1.0:

                    https://issues.jboss.org/browse/SWITCHYARD-1534

                    1 of 1 people found this helpful
                    • 7. Re: How SY handles RuntimeCamelException?
                      herkules

                      Thanks Keith for your time. I can confirm that org.switchyard is set to DEBUG and I use file log and I see DEBUG logs from switchyard. What class should log the exception?

                       

                      I am new to SY/Camel so I am learning. What I need is to read a message out of a JMS queue and store it as a file with given name. For optimistic scenario it works but I want to handle errors that occur during file saving such as if the file already exists. In that case I may want to put the message to another queue or to another folder as I cannot loose it. I have no idea how should I implement it with SY 0.8 as onException nor doTry/doCatch does nothing.

                       

                          <service name="Message2File" promote="Message2FileBuilder/Message2File">

                            <jms:binding.jms xmlns:jms="urn:switchyard-component-camel-jms:config:1.0">

                              <jms:contextMapper includes=".*" />

                              <jms:queue>wcs.tst.mti.queue</jms:queue>

                              <jms:connectionFactory>qpidConnectionFactory</jms:connectionFactory>

                            </jms:binding.jms>

                          </service>

                       

                          <component name="Message2FileBuilder">

                            <implementation.camel xmlns="urn:switchyard-component-camel:config:1.0">

                              <java class="cz.wood.switchyard.routes.Message2FileRouteBuilder" />

                            </implementation.camel>

                       

                            <service name="Message2File">

                              <interface.java interface="cz.wood.switchyard.services.Message2File" />

                            </service>

                       

                            <reference multiplicity="1..1" name="Message2FileReference">

                              <swyd:interface.esb xmlns:swyd="urn:switchyard-config:switchyard:1.0" inputType="java:java.lang.String" />

                            </reference>

                          </component>

                       

                          <reference name="Message2FileReference" multiplicity="1..1" promote="Message2FileBuilder/Message2FileReference">

                            <file:binding.file xmlns:file="urn:switchyard-component-camel-file:config:1.0">

                              <file:contextMapper includes="CamelFileName" />

                              <file:directory>/temp/MTI/outbound</file:directory>

                              <file:autoCreate>true</file:autoCreate>

                              <file:tempFileName>temp/temp-$%7Bdate:now:yyyyMMddHHmmssSSS%7D.txt</file:tempFileName>

                              <file:fileExist>Fail</file:fileExist>

                            </file:binding.file>

                          </reference>   

                       

                      package cz.wood.switchyard.services;

                      public interface Message2File {

                          public void process(String payload);

                      }

                       

                      @Route(value = Message2File.class)

                      public class Message2FileRouteBuilder extends RouteBuilder {

                       

                                @Override

                                public void configure() throws Exception {

                              from("switchyard://Message2File").

                                  setHeader(Exchange.FILE_NAME, header(Constants.MSG_HEADER_FILE_NAME)).

                              to("log://Message2FileRouteLogger?level=info&showHeaders=true&showProperties=true&maxChars=1024&multiline=true").

                              to("switchyard://Message2FileReference");

                            }

                      }

                      • 8. Re: How SY handles RuntimeCamelException?
                        herkules

                        Adding outputType to

                         

                              <reference multiplicity="1..1" name="Message2FileReference">

                                <swyd:interface.esb xmlns:swyd="urn:switchyard-config:switchyard:1.0" inputType="java:java.lang.String" outputType="java:java.lang.String" />

                              </reference>

                         

                        made the needed change, Jan

                        • 9. Re: How SY handles RuntimeCamelException?
                          kcbabo

                          Thanks for the config.  Once SWITCHYARD-1534 is addressed you should be able to use an in-only MEP and still get runtime errors/faults reported.