Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saga example #1097

Closed
zhfeng opened this issue Nov 26, 2019 · 11 comments
Closed

Saga example #1097

zhfeng opened this issue Nov 26, 2019 · 11 comments
Labels
status/waiting-for-feedback Needs some feedback

Comments

@zhfeng
Copy link
Contributor

zhfeng commented Nov 26, 2019

I'm working on the camel-saga-quickstart to run with the camel-k.

At first, I added the detection to check "*\.saga\(\).*" and add camel-lra dependency. It works fine and I get the example running but throws exception

Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> Saga -> [[SetHeader[id, header(CamelTimerCounter)], SetHeader[CamelHttpMethod, POST], Log[Executing saga #${header.id}], To[http://camel-saga-train-service:8080/api/train/buy/seat], To[http://camel-saga-flight-service:8080/api/flight/buy]]] <<< in route: Route(route1)[From[timer:clock?period=5s] -> [Saga -> [[SetH... because of Cannot find a CamelSagaService
	at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:379)
	at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:108)
	at org.apache.camel.impl.DefaultModel.start(DefaultModel.java:326)
	at org.apache.camel.impl.DefaultModel.startRoute(DefaultModel.java:300)
	at org.apache.camel.impl.DefaultModel.startRouteDefinitions(DefaultModel.java:293)
	at org.apache.camel.impl.DefaultModel.startRouteDefinitions(DefaultModel.java:272)
	at org.apache.camel.impl.AbstractModelCamelContext.startRouteDefinitions(AbstractModelCamelContext.java:322)
	at org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:2590)
	at org.apache.camel.impl.engine.AbstractCamelContext.lambda$doStart$2(AbstractCamelContext.java:2438)
	at org.apache.camel.impl.engine.AbstractCamelContext.doWithDefinedClassLoader(AbstractCamelContext.java:2455)
	at org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2436)
	at org.apache.camel.support.service.ServiceSupport.start(ServiceSupport.java:99)
	at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2345)
	at org.apache.camel.k.main.ApplicationRuntime$MainAdapter.doStart(ApplicationRuntime.java:177)
	at org.apache.camel.support.service.ServiceSupport.start(ServiceSupport.java:99)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:77)
	at org.apache.camel.k.main.ApplicationRuntime.run(ApplicationRuntime.java:70)
	at org.apache.camel.k.main.Application.main(Application.java:42)
Caused by: org.apache.camel.RuntimeCamelException: Cannot find a CamelSagaService
	at org.apache.camel.reifier.SagaReifier.findSagaService(SagaReifier.java:108)
	at org.apache.camel.reifier.SagaReifier.createProcessor(SagaReifier.java:76)
	at org.apache.camel.reifier.ProcessorReifier.makeProcessorImpl(ProcessorReifier.java:574)
	at org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:540)
	at org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:250)
	at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:377)

It looks like there is no CamelSagaService. I checked the camel-lra-starter which invokes the following

       LRASagaService service = new LRASagaService();

        Map<String, Object> parameters = new HashMap<>();
        IntrospectionSupport.getProperties(configuration, parameters, null, false);
        CamelPropertiesHelper.setCamelProperties(camelContext, service, parameters, false);

        camelContext.addService(service);

So I wonder how we can add a CamelSagaService in camel-k similarly ?

@nicolaferraro
Copy link
Member

We should leverage the service loader mechanism available in Camel for such kind of things, I was expecting the service to be recognized automatically.

Also properties should be recognized by Camel main in order to be used in Camel K.

@zhfeng
Copy link
Contributor Author

zhfeng commented Nov 26, 2019

Thanks @nicolaferraro , so the feature has not been supported in the camel-k currently ?

@nicolaferraro
Copy link
Member

I meant that if we fix it in Camel, we can avoid adding boilerplate in Camel K, but it should be supported.

You can bind a LRASagaService using bean binding also in Camel K.

@zhfeng
Copy link
Contributor Author

zhfeng commented Nov 26, 2019

sure, I get it.

@zhfeng
Copy link
Contributor Author

zhfeng commented Nov 29, 2019

@nicolaferraro can you review #1109 please ?

@zhfeng
Copy link
Contributor Author

zhfeng commented Nov 29, 2019

I just add the LRASagaService in the router configuration.

@lburgazzoli
Copy link
Contributor

@zhfeng @apache/camel-committers should we add a saga customizer in camel-k-runtime ? or will this issue be fixed on camel side ?

@lburgazzoli lburgazzoli added the status/waiting-for-feedback Needs some feedback label Jun 5, 2020
@zhfeng
Copy link
Contributor Author

zhfeng commented Jun 5, 2020

@lburgazzoli I think it could be better to be fixed on the camel side if possible.

@lburgazzoli
Copy link
Contributor

@zhfeng o can you open an issue on camel side and close this one ?

@zhfeng
Copy link
Contributor Author

zhfeng commented Jun 5, 2020

yeah, I will

@zhfeng
Copy link
Contributor Author

zhfeng commented Jun 9, 2020

I raise CAMEL-15164 for services recognize automatically and since the Saga examples have been merged. So I close this issue now and if the CAMEL-15164 is resolved in the future camel releases, I would like to investigate to see how we can leverage it to improve this example.

@zhfeng zhfeng closed this as completed Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/waiting-for-feedback Needs some feedback
Projects
None yet
Development

No branches or pull requests

3 participants