[ 
https://issues.apache.org/jira/browse/CAMEL-19342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17722068#comment-17722068
 ] 

rodrigo coelho edited comment on CAMEL-19342 at 5/12/23 9:05 AM:
-----------------------------------------------------------------

What i see so far is:
h3. Iteration 1

The method *DefaultModel.addRouteDefinitions* is called with the 2 route 
definitions:
{code:java}
Route(demo-test-0)[From[direct:demo-test-0] -> 
[OnException[[java.lang.Exception] -> []], 
LoadBalanceType[FailoverLoadBalancer, 
[To[http://localhost:8081/test?bridgeEndpoint=true&throwExceptionOnFailure=false]]]]]

Route(rd-demo-test-0)[From[rest:get:/demo0?matchOnUriPrefix=true] -> 
[To[direct:demo-test-0]]]{code}
The class attribute: *routeDefinitions* is _empty_
h3. Iteration 2

The method *DefaultModel.addRouteDefinitions* is called with the 2 route 
definitions:
{code:java}
Route(demo-test-1)[From[direct:demo-test-1] -> 
[OnException[[java.lang.Exception] -> []], 
LoadBalanceType[FailoverLoadBalancer, 
[To[http://localhost:8081/test?bridgeEndpoint=true&throwExceptionOnFailure=false]]]]]

Route(rd-demo-test-1)[From[rest:get:/demo1?matchOnUriPrefix=true] -> 
[To[direct:demo-test-1]]] {code}
The class attribute: *routeDefinitions* is *NOT* empty:
{code:java}
Route(rd-demo-test-0)[From[rest://get:/demo0?matchOnUriPrefix=true&routeId=rd-demo-test-0]
 -> [OnException[[java.lang.Exception] -> []], 
LoadBalanceType[FailoverLoadBalancer, 
[To[http://localhost:8081/test?bridgeEndpoint=true&throwExceptionOnFailure=false]]]]]
 {code}
I think the problem shoud be around here, because we see a REST route with 3 
elements:
1 - OnException

2- Load Balancer

3 - ToDefinition (where it fails)

*This is the "inlined" route added from the first iteration (rd-demo-test-0), 
so i think it fails to be removed by the end of first iteration.*

I think that after this code: (DefaultModel:248)
{code:java}
if (shouldStartRoutes()) {
       
getCamelContext().adapt(ModelCamelContext.class).startRouteDefinitions(list);
} {code}
The class attribute *routeDefinitions* needs to be cleared. 

If i clear the class attribute: *routeDefinitions* after each iteration, i 
don't the same issue anymore and the routes are deployed inlined. 
{code:java}
2023-05-12 11:03:31.208  INFO 289566 --- [           main] 
io.surisoft.demo.DemoRouteBuilder        : Route 0 deployed!
2023-05-12 11:03:47.948  INFO 289566 --- [           main] 
io.surisoft.demo.DemoRouteBuilder        : Route 1 deployed!{code}
If i stop the server:
{code:java}
2023-05-12 11:05:30.852  INFO 289566 --- [ionShutdownHook] 
o.a.c.impl.engine.AbstractCamelContext   : Apache Camel 3.20.4 (camel-1) is 
shutting down (timeout:45s)
2023-05-12 11:05:30.861  INFO 289566 --- [ionShutdownHook] 
o.a.c.impl.engine.AbstractCamelContext   : Routes stopped (stopped:2)
2023-05-12 11:05:30.861  INFO 289566 --- [ionShutdownHook] 
o.a.c.impl.engine.AbstractCamelContext   :     Stopped rd-demo-test-1 
(rest://get:/demo1)
2023-05-12 11:05:30.861  INFO 289566 --- [ionShutdownHook] 
o.a.c.impl.engine.AbstractCamelContext   :     Stopped rd-demo-test-0 
(rest://get:/demo0) {code}


was (Author: coelhro):
What i see so far is:
h3. Iteration 1

The method *DefaultModel.addRouteDefinitions* is called with the 2 route 
definitions:
{code:java}
Route(demo-test-0)[From[direct:demo-test-0] -> 
[OnException[[java.lang.Exception] -> []], 
LoadBalanceType[FailoverLoadBalancer, 
[To[http://localhost:8081/test?bridgeEndpoint=true&throwExceptionOnFailure=false]]]]]

Route(rd-demo-test-0)[From[rest:get:/demo0?matchOnUriPrefix=true] -> 
[To[direct:demo-test-0]]]{code}
The class attribute: *routeDefinitions* is _empty_
h3. Iteration 2

The method *DefaultModel.addRouteDefinitions* is called with the 2 route 
definitions:
{code:java}
Route(demo-test-1)[From[direct:demo-test-1] -> 
[OnException[[java.lang.Exception] -> []], 
LoadBalanceType[FailoverLoadBalancer, 
[To[http://localhost:8081/test?bridgeEndpoint=true&throwExceptionOnFailure=false]]]]]

Route(rd-demo-test-1)[From[rest:get:/demo1?matchOnUriPrefix=true] -> 
[To[direct:demo-test-1]]] {code}
The class attribute: *routeDefinitions* is *NOT* empty:
{code:java}
Route(rd-demo-test-0)[From[rest://get:/demo0?matchOnUriPrefix=true&routeId=rd-demo-test-0]
 -> [OnException[[java.lang.Exception] -> []], 
LoadBalanceType[FailoverLoadBalancer, 
[To[http://localhost:8081/test?bridgeEndpoint=true&throwExceptionOnFailure=false]]]]]
 {code}
I think the problem shoud be around here, because we see a REST route with 3 
elements:
1 - OnException

2- Load Balancer

3 - ToDefinition (where it fails)

*This is the "inlined" route added from the first iteration (rd-demo-test-0), 
so i think it fails to be removed by the end of first iteration.*

I think that after this code: (DefaultModel:248)
{code:java}
if (shouldStartRoutes()) {
       
getCamelContext().adapt(ModelCamelContext.class).startRouteDefinitions(list);
} {code}
The class attribute *routeDefinitions* needs to be cleared. 

> Rest Inline Routes mixed with direct routes.
> --------------------------------------------
>
>                 Key: CAMEL-19342
>                 URL: https://issues.apache.org/jira/browse/CAMEL-19342
>             Project: Camel
>          Issue Type: Bug
>          Components: came-core
>    Affects Versions: 3.20.4, 4.0-M3
>            Reporter: rodrigo coelho
>            Priority: Major
>
> Hello, 
> For more information please follow Zulip thread:
> [https://camel.zulipchat.com/#narrow/stream/257301-camel-spring-boot/topic/Inline.20Routes.20.28Default.20Model.29]
> Here is my code:
> [https://github.com/rodrigoserracoelho/rest-demo]
> Do let me know if you need more info.
> Thanks.
> BR,
> Rodrigo



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

Reply via email to