Hi, responses inline. Il lun 16 mar 2020, 18:42 ski n <raymondmees...@gmail.com> ha scritto:
> Hi all, > > In the last presentation there was also a short demo on CamelK. That looked > very interesting, but I have some questions on how does it work, especially > in more complex use cases. > > Here are some questions I have: > > Question 1: Dependency resolution > > In CamelK you can provide the following: > > from("imap://ad...@myserver.com") > .to("seda:output") > > Because imap is not part of core this will start the dependency resolution. > How does this work? How does CamelK know it needs the mail component as > dependency? Is there some kind of fixed mapping between the scheme and > component? > Component IDs are known and listed in an artifact called "camel catalog" for each release. So camel k does the reverse mapping from the catalog and adds the needed camel library. > Say for example I have the following route: > > from("seda:input") > .to("seda:output") > > This is then run on Kubernetes/CamelK. Then I change this to: > > from("imap://ad...@myserver.com") > .to("seda:output") > > Is this dependency add as "Maven" dependency and then recompiled? Or is the > jar downloaded and the added? Or something else... > The integration goes in a "Building Kit" state where a container image is built for the new integration. The algorithm is complex, but it's likely in this case that the image for seda is enhanced with new jars for the imap component and that results in a new image. Building the image takes some more time, but it's done transparently. If, instead, you don't change the used components, no new jar is added and the redeployment is much faster. > > Question 2: Multiple files > > In the Java example: > https://camel.apache.org/camel-k/latest/languages/java.html > > There is one simple route with one file. How does it work in more complex > cases when there are multiple files? > > For example I have the following package: > > Registry.java > Route1.java > Route2.java > Processor.java > Connection.java > > In Route1.java data is retrieved with the SQL component out of an Oracle > database, also this routs calls a processor. In route 2 the pojo is > marshalled to JSON and send to a HTTP endpoint. In registry things like > SSL, metrics are configured. In the processor some mapping is done and in > the connection the Oracle driver is configured. > > Can I run a whole package with the Kamel CLI? How does Kamel gets for > example the dependency for the Oracle driver? > Camel k creates a base images that is suitable for all the routes (i.e. with all the dependencies required by all routes), since they are run in the same JVM in the end. Additional dependencies can be provided using the "-d mvn:group:artifact:version": that way you can add the Oracle driver. > > > > > > Question 3: Configure and Management from Java. > > What I believe is that the Kamel CLI client is written in Go. So the flow > is as follows: > > A) Write some Camel code in the available languages. > > https://camel.apache.org/camel-k/latest/languages/languages.html > > B) Use Kamel CLI to run/deploy it on Kubernetes > > C) Use something like hawt.io to manage it. > > Is this also available from Java (or as Camel component) to > configure/deploy it from Java code and to manage it from Java code? > No, "kamel" should be used to deploy integrations. But integrations are Kubernetes custom resources, so they also have a YAML/json representation in the cluster and you can use Kubernetes tools to manage them (like kubectl). But the workflow should not start from Java. Also there's no need to create a project structure (like a maven structure): we prefer a non-structured approach and ideally camel k integrations should be made of one/few files for portability. > Question 4: Scaling > > Kubernetes is ideal for horizontal scaling. How does this work with CamelK? > Say I have the following two routes: > > from("activemq:topic:foo") > .to("sftp://sample.com/someDir") > > from("sftp://sample.com/someDir") > .to("activemq:topic:foo") > > When the routes are scaled. How does CamelK prevent that in the first route > multiple messages arrive in the same FTP directory. And in the second > example there are multiple routes listening to the same directory and get > file locks. Does it have possibilities how to scale the routes? > There's support for master component of you need to run only one instance of the route. But in this case you want to scale, so you've to reason using knowledge from classic camel. E.g. in the first case I'd use an approach to name files so to avoid collision (the POD_NAME environment variable is populated with the name of the pod instance if you need a way to avoid collision). For the second route, I expect that sftp provides fine grained lock on the files, so it should scale to multiple instances correctly. > Kind regards, > > Raymond >