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

Basic module structure for Camel K projects #1135

Closed
nicolaferraro opened this issue Dec 11, 2019 · 6 comments
Closed

Basic module structure for Camel K projects #1135

nicolaferraro opened this issue Dec 11, 2019 · 6 comments
Labels
area/ux Improves user experience
Milestone

Comments

@nicolaferraro
Copy link
Member

Going forward version 1.0.0 we should think about how people will organize complex integrations that they will run in production. We strongly want to keep a single file model for the integrations, but often you need to provide resources, like:

  • Properties
  • API definitions
  • Transformation and mapping files
  • Test files (yet to come)

That means that even in a simple project composed of few integrations that interact together, it will be difficult to understand what resources belong to what integration.

E.g. When you have multiple integrations, which one does an application.properties file refer to?

We need to define some module structure for integrations. It may be something encoded in the kamel CLI (e.g. kamel scaffold name) or simply a best practice we propose also in the examples.

The simplest model I can imagine is creating as less structure as possible, keeping a minimum of visual order in a project.

e.g.

module1
  module1integration.groovy
  application.properties
  trasnform.xslt

module2
  tests
    moduletest.feature
    moduletest2.feature
    moduletest3.feature
  module2integration1.groovy
  module2integration2.groovy
  application.properties
  README.md

rootmoduleintegration.groovy

Questions:

@lburgazzoli , @davsclaus, @astefanutti , @jamesnetherton, @valdar, @oscerd

@nicolaferraro nicolaferraro added the area/ux Improves user experience label Dec 11, 2019
@nicolaferraro nicolaferraro added this to the 1.0.0 milestone Dec 11, 2019
@davesargrad
Copy link

davesargrad commented Dec 13, 2019

@nicolaferraro I was about to ask this. So is it true that I currently cant create an integration that uses several java classes defined in several files? Is this a major limitation, or can I simply place all those class definitions into a single ".java" file?

I would think that many meaningful routes may have a handful of classes, and modularity suggests that these should go in separate files.

An example of an atomikos springboot application, that i am working to find a kamel equivalent of (still using atomikos, just not using springboot) is found here

If you look particularly at the AccountService, one can imagine createAccountAndNotify as a kamel enabled RESTful route that implements a kamel-enabled route both to a jdbc endpoint, and to a jms endpoint. The composite createAccountAndNotify transaction would then be protected via camels support for XA transactions, and atomikos implementation of an XA transaction manager.

The atomikos application is clean, and you'd hope that a kamel variant still preserves the essence of the class structure.

@davesargrad
Copy link

davesargrad commented Dec 13, 2019

One thing I absolutely could do is to put the building block classes into a "jar" file that is then loaded as a maven dependency. I know how to do this, and that may be the proper way to go, and to live with the single file, per integration, restriction in kamel

@nicolaferraro
Copy link
Member Author

You can run multiple files in a Camel K integration, it works also if they are written in different languages. Just run:

kamel run --name thename Routes1.java Routes2.java others.xml

It runs as a single integration named thename.

The "single file model" is the default model we're pushing for, but if it makes sense, I think there are no problems in collapsing multiple integration files into a single integration (often it makes sense for a performance point of view, to save some CPU/memory since it uses a single JVM).

I feel that generic supporting methods and classes are better placed in an external "jar", so that one separates the glue (routes) from the business logic.

@davesargrad
Copy link

davesargrad commented Dec 13, 2019

@nicolaferraro Wow.. thats cool. Sounds like we have a couple of good options, and our options will be enhanced as you solidify your support for an integration structure that includes multiple resources/files.

@nicolaferraro nicolaferraro modified the milestones: 1.0.0, 1.0.0-RC2 Dec 18, 2019
@nicolaferraro nicolaferraro modified the milestones: 1.0.0-RC2, 1.0.0-future Feb 6, 2020
@nicolaferraro nicolaferraro modified the milestones: 1.0.0, post 1.0.0 Apr 28, 2020
@nicolaferraro
Copy link
Member Author

Outdated

@samuelhnrq
Copy link

Wait what happened, still curious to know how is this going to be handled? Outdated why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ux Improves user experience
Projects
None yet
Development

No branches or pull requests

3 participants