You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Nils Wendland <ni...@pickert.de.INVALID> on 2021/03/01 08:31:53 UTC

Issue with Exception Handling in Iota route

Hi,
I am trying to build a camel route that sends messages from a ActiveMQ Queue to Iota Tangle. The route is working, however when I try to simulate that tangle is unavailable, the exception is not handled by the DoTry /DoCatch and thus is thrown.
My understanding is that the Exception is thrown in Iota class which has its own error handling. Then additionally an IllegalStateException is thrown which is handled by DoTry.
Do you have any ideas what I might do to enforce the original error being handled by DOTry or at least that the exception is not thrown?
The exception is thrown in the .to("iota..." line

Here are some details about my project that might help you:

Camel version: 3.7.2.
Spring Boot version 2.4.1

from("activemq:queue:Projektarbeit").doTry()

                     // im msg body String message = "{hello world}";

                     .setHeader("CamelIOTAToAddress", constant(
                          "MMNDD9DWUEVKEIVHFAOMHISHXJSGXWBJFYEQPOQKSVGZZFLTUUPBACNQZTAKXR9TFVKBGYSNSPHRNKKHAPEIEHYEAX"))
                     .setHeader("CamelIOTASeed",
                          constant("NWNWJDBYZG9EVPDHENEAABRHSQJNIZFPRMPAWUBZV9LVKPJTVSQNFKKNLBOQMGWVZLCKHVOLQJDYAV9JN"))
                     .setHeader("CamelIOTAValue", constant(0))
                     // split message into Iota size
                     .process(new Processor() {
                          public void process(Exchange exchange) {
                               String message = exchange.getIn().getBody(String.class);
                               slicer.slice(message);
                          };
                     }).process(new Processor() {

                          @Override
                          public void process(Exchange exchange) {
                               // TODO Auto-generated method stub
                               throw new RuntimeException("runtime");
                          }

                     })

                     // message -> iota //depth standard is 3
                     .to("iota:good?url=https://nodes.thetangle.org:443&operation=sendTransfer&tag=DDXCRCZCTCFDHD9999999999999&depth=4&minWeightMagnitude=14&securityLevel=1")
                     .doCatch(Exception.class).process(new Processor() {
                          public void process(Exchange exchange) {
                               final Throwable ex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);

                               String message = " " + exchange.getIn().getBody(String.class);
                               exchange.getIn().setBody(ex.getClass().getCanonicalName() + message);
                          };
                     }).to("activemq:queue:UnserTest").stop()



Thanks for your help


Best Regards

Nils Wendland
[Ein Bild, das Person, Text, Schild, Frau enthält.  Automatisch generierte Beschreibung]<https://www.pickert.de/rqm61>  [cid:image002.jpg@01D70E7B.4C5F28B0] <https://www.pickert.de/produktuebersicht-idos/>

Geschäftsführer: Sven O. Rimmelspacher
Amtsgericht Mannheim HRB 104443
USt-ID: DE143555026



Re: Issue with Exception Handling in Iota route

Posted by Claus Ibsen <cl...@gmail.com>.
Hi Niels

Thanks for bringing this to us. Can you maybe pin point to where inside
camel-iata you see this exception and its own error handling?
Would like to see more what would be the reason for this, instead of just
letting the exception being thrown to let Camels error handling deal with
it right away

On Mon, Mar 1, 2021 at 9:54 AM Nils Wendland
<ni...@pickert.de.invalid> wrote:

> Hi,
>
> I am trying to build a camel route that sends messages from a ActiveMQ
> Queue to Iota Tangle. The route is working, however when I try to simulate
> that tangle is unavailable, the exception is not handled by the DoTry
> /DoCatch and thus is thrown.
>
> My understanding is that the Exception is thrown in Iota class which has
> its own error handling. Then additionally an IllegalStateException is
> thrown which is handled by DoTry.
>
> Do you have any ideas what I might do to enforce the original error being
> handled by DOTry or at least that the exception is not thrown?
>
> The exception is thrown in the .to(“iota…” line
>
>
>
> Here are some details about my project that might help you:
>
>
>
> Camel version: 3.7.2.
>
> Spring Boot version 2.4.1
>
>
>
> from("activemq:queue:Projektarbeit").doTry()
>
>
>
>                      // *im* *msg* body String message = "{hello world}";
>
>
>
>                      .setHeader("CamelIOTAToAddress", constant(
>
>
> "MMNDD9DWUEVKEIVHFAOMHISHXJSGXWBJFYEQPOQKSVGZZFLTUUPBACNQZTAKXR9TFVKBGYSNSPHRNKKHAPEIEHYEAX"
> ))
>
>                      .setHeader("CamelIOTASeed",
>
>                           constant(
> "NWNWJDBYZG9EVPDHENEAABRHSQJNIZFPRMPAWUBZV9LVKPJTVSQNFKKNLBOQMGWVZLCKHVOLQJDYAV9JN"
> ))
>
>                      .setHeader("CamelIOTAValue", constant(0))
>
>                      // split message into *Iota* size
>
>                      .process(*new* Processor() {
>
>                           *public* *void* process(Exchange exchange) {
>
>                                String message = exchange
> .getIn().getBody(String.*class*);
>
>                                slicer.slice(message);
>
>                           };
>
>                      }).process(*new* Processor() {
>
>
>
>                           @Override
>
>                           *public* *void* process(Exchange exchange) {
>
>                                // *TODO* Auto-generated method stub
>
>                                *throw* *new* RuntimeException("runtime");
>
>                           }
>
>
>
>                      })
>
>
>
>                      // message -> *iota* //depth standard is 3
>
>                      .to(
> "iota:good?url=https://nodes.thetangle.org:443&operation
> =sendTransfer&tag=DDXCRCZCTCFDHD9999999999999&depth=4&minWeightMagnitude=14&securityLevel=1"
> )
>
>                      .doCatch(Exception.*class*).process(*new*
> Processor() {
>
>                           *public* *void* process(Exchange exchange) {
>
>                                *final* Throwable ex = exchange
> .getProperty(Exchange.*EXCEPTION_CAUGHT*, Throwable.*class*);
>
>
>
>                                String message = " " + exchange
> .getIn().getBody(String.*class*);
>
>                                exchange.getIn().setBody(ex.getClass().getCanonicalName()
> + message);
>
>                           };
>
>                      }).to("activemq:queue:UnserTest").stop()
>
>
>
>
>
>
>
> Thanks for your help
>
>
>
>
>
> Best Regards
>
>
>
> Nils Wendland
>
> [image: Ein Bild, das Person, Text, Schild, Frau enthält. Automatisch
> generierte Beschreibung] <https://www.pickert.de/rqm61>
> <https://www.pickert.de/produktuebersicht-idos/>
>
>
>
> Geschäftsführer: Sven O. Rimmelspacher
>
> Amtsgericht Mannheim HRB 104443
>
> USt-ID: DE143555026
>
>
>
>
>


-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2