[ 
https://issues.apache.org/jira/browse/CAMEL-21216?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Zheng Feng resolved CAMEL-21216.
--------------------------------
    Resolution: Fixed

> Apache Camel LRA does not work with Oracle MicroTX LRA coordinator
> ------------------------------------------------------------------
>
>                 Key: CAMEL-21216
>                 URL: https://issues.apache.org/jira/browse/CAMEL-21216
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-lra
>    Affects Versions: 4.7.0
>            Reporter: Dirk Fiedler
>            Assignee: Zheng Feng
>            Priority: Minor
>             Fix For: 4.8.1, 4.9.0
>
>
> {color:#000000}Hi Team,{color}
> {color:#000000}we are using the Apache Camel LRA components within Java 
> Springboot projects to implement saga services.{color}
> {color:#000000}Till now, we are using Narayana as an LRA-Coordinator. Now we 
> want to switch to Oracl MicroTX {color}
> {color:#000000}(https://docs.oracle.com/en/database/oracle/transaction-manager-for-microservices/24.2/tmmdg/lra-transaction-protocol.html).{color}
> {color:#000000}After configuring Oracle MircoTX instead of Narayana, we are 
> facing two problems within the {color}
> {color:#000000}Apache Camel LRA component code.{color}
> {color:#0451a5}1){color}{color:#000000} While joining an LRA Transaction, the 
> payload sent by Apache Camel is URL encoded{color}
> {color:#0451a5}2){color}{color:#000000} The Query parameter sent by Oracle 
> LRA coordinator are url encoded, but will not be decoded by Apache Camal LRA 
> (see also: CAMEL-21197){color}
> {color:#000000}I will set up a branch with my suggested code changes and link 
> this afterwards to this jira bug.{color}
> {color:#000000}The code changes are completely backwards compatible with 
> Narayana (already tested).{color}
> {color:#0451a5}1){color}{color:#000000} Joining an LRA Transaction{color}
> {color:#000000}The class 'LRAClient' is using 'LRAUrlBuilder' inside Method 
> 'join'. All parts of the http put body are url encoded. {color}
> {color:#000000}Within Oracle LRA Coordinator log i can see the incomming 
> request from Apache Camel:{color}
>  
> {code:java}
> <https://k5-mmeeasysaga.qa-servicebuilder-dev.svc.cluster.local/camel/compensate?Camel-Saga-Complete=direct%3A%2F%2Fsaga1_sagaService_complete>;
>  
> rel=compensate,<https://k5-mmeeasysaga.qa-servicebuilder-dev.svc.cluster.local/camel/complete?Camel-Saga-Complete=direct%3A%2F%2Fsaga1_sagaService_complete>;
>  rel=complete{code}
> {color:#000000}This url encoded query param 
> 'Camel-Saga-Complete=direct%3A%2F%2Fsaga1_sagaService_complete' will be 
> encoded again on Oracle LRA Coordinator side.{color}
> {color:#000000}This is causing the error message within Apache Camel 
> LRA:{color}
>  
> {code:java}
> o.a.c.RuntimeCamelException: Cannot join LRA  at 
> o.a.c.s.l.LRAClient.lambda$join$2(LRAClient.java:138)  ... 10 common frames 
> omitted Wrapped by: j.u.c.CompletionException: 
> org.apache.camel.RuntimeCamelException: Cannot join LRA  at 
> j.u.c.CompletableFuture.encodeThrowable(Unknown Source)  at 
> j.u.c.CompletableFuture.completeThrowable(Unknown Source)  at 
> j.u.c.CompletableFuture$UniApply.tryFire(Unknown Source)  at 
> j.u.c.CompletableFuture.postComplete(Unknown Source)  at 
> j.u.c.CompletableFuture.postFire(Unknown Source)  at 
> j.u.c.CompletableFuture$UniWhenComplete.tryFire(Unknown Source)  at 
> j.u.c.CompletableFuture$Completion.exec(Unknown Source)  at 
> j.u.c.ForkJoinTask.doExec(Unknown Source)  at 
> j.u.c.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)  at 
> j.u.c.ForkJoinPool.scan(Unknown Source)  at 
> j.u.c.ForkJoinPool.runWorker(Unknown Source)  at 
> j.u.c.ForkJoinWorkerThread.run(Unknown Source){code}
>  
> {color:#000000}When logging the result http code and body{color}
>  
> {code:java}
> LOG.error("error while joining LRA: {} / {}", response.statusCode(), 
> response.body());{code}
> {color:#000000}i am getting this:{color}
> {code:java}
> error while joining LRA: 400 / error: URL is double encoded{code}
> {color:#000000}The problem can be solved by not url encoding the given urls 
> within the joinLRA payload.{color}
>  
> org.apache.camel.service.lra.LRAUrlBuilder -> query:
>  
> This code should not be executed:
>  
> {code:java}
> key = URLEncoder.encode(toNonnullString(key), StandardCharsets.UTF_8.name()); 
>  value = URLEncoder.encode(toNonnullString(value), 
> StandardCharsets.UTF_8.name()); 
>  {code}
>  
> {color:#0451a5}2){color}{color:#000000} Decode given query parameter from 
> Oracle LRA-Coordinator call{color}
> {color:#000000}After solving 1), i am getting a new exception:{color}
> {code:java}
> j.l.IllegalArgumentException: URI direct%3A%2F%2Fsaga1_sagaService_complete 
> is not allowed  at 
> o.a.c.s.l.LRASagaRoutes.verifyRequest(LRASagaRoutes.java:107)  at 
> o.a.c.s.p.DelegateSyncProcessor.process(DelegateSyncProcessor.java:65)  at 
> o.a.c.p.e.RedeliveryErrorHandler$SimpleTask.handleFirst(RedeliveryErrorHandler.java:440)
>   at 
> o.a.c.p.e.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:416)
>   at 
> o.a.c.i.e.DefaultReactiveExecutor$Worker.doRun(DefaultReactiveExecutor.java:199)
>   at 
> o.a.c.i.e.DefaultReactiveExecutor$Worker.executeReactiveWork(DefaultReactiveExecutor.java:189)
>   at 
> o.a.c.i.e.DefaultReactiveExecutor$Worker.tryExecuteReactiveWork(DefaultReactiveExecutor.java:166)
>   at 
> o.a.c.i.e.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148)
>   at 
> o.a.c.i.e.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59)
>   at o.a.c.p.Pipeline.process(Pipeline.java:163)  at 
> o.a.c.i.e.CamelInternalProcessor.processNonTransacted(CamelInternalProcessor.java:346)
>   at 
> o.a.c.i.e.CamelInternalProcessor.process(CamelInternalProcessor.java:322)  at 
> o.a.c.i.e.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:82)
>   at o.a.c.s.AsyncProcessorSupport.process(AsyncProcessorSupport.java:32)  at 
> o.a.c.h.c.CamelServlet.doExecute(CamelServlet.java:313)  at 
> o.a.c.h.c.CamelServlet.doService(CamelServlet.java:235)  at 
> o.a.c.h.c.CamelServlet.handleService(CamelServlet.java:111)  at 
> o.a.c.h.c.CamelServlet.service(CamelServlet.java:97)  at 
> j.s.h.HttpServlet.service(HttpServlet.java:614)  ... 5 frames excluded  at 
> k.s.s.s.c.SagaContextFilter.doFilterInternal(SagaContextFilter.java:52)  ... 
> 4 frames excluded  at 
> o.s.s.w.FilterChainProxy.lambda$doFilterInternal$3(FilterChainProxy.java:231) 
>  at 
> o.s.s.w.ObservationFilterChainDecorator$FilterObservation$SimpleFilterObservation.lambda$wrap$1(ObservationFilterChainDecorator.java:479)
>   at 
> o.s.s.w.ObservationFilterChainDecorator$AroundFilterObservation$SimpleAroundFilterObservation.lambda$wrap$1(ObservationFilterChainDecorator.java:340)
>   at 
> o.s.s.w.ObservationFilterChainDecorator.lambda$wrapSecured$0(ObservationFilterChainDecorator.java:82)
>   ... 2 frames excluded  at 
> o.s.s.w.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
>   ... 110 frames truncated{code}
>  
> {color:#000000}After finalizing the saga, the Oracle LRA-Coordinator is 
> calling the 'onComplete' for all participants and the service.{color}
>  
> {code:java}
>  PUT 
> /camel/complete?Camel-Saga-Compensate=direct%3A%2F%2Fsaga1_participant1_compensate&Camel-Saga-Complete=direct%3A%2F%2Fsaga1_participant1_complete{code}
> {color:#000000}Within 
> o.a.c.s.l.LRASagaRoutes.verifyRequest(LRASagaRoutes.java:107) the extracted 
> query param 'Camel-Saga-Compensate' is still url encoded:{color}
> {code:java}
>  direct%3A%2F%2Fsaga1_sagaService_complete{code}
> {color:#000000}Therefore the check within LRASagaRoutes.verifyRequest fails, 
> because the valid (indexed) uri is{color}
> {code:java}
>  direct://saga1_sagaService_complete{code}
> {color:#000000}The problem can completely solved by CAMEL-21197. In the 
> meantime in will provide a suggestion for an workaround.{color}
> {color:#000000}best regards{color}
> {color:#000000}Dirk{color}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to