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

Kamelet using Java DSL #2117

Closed
arthurdm opened this issue Mar 12, 2021 · 4 comments
Closed

Kamelet using Java DSL #2117

arthurdm opened this issue Mar 12, 2021 · 4 comments

Comments

@arthurdm
Copy link

The Kamelet page outlines various examples with YAML DSL, but all of the integrations I have been writing as using the Java DSL.

The page says:

Each Kamelet contains a YAML-based Camel DSL that provides the actual implementation of the connector

So is there a way to write a Kamelet that uses the Java DSL?

@nicolaferraro
Copy link
Member

The route template part (i.e. the part that can use the property placeholders) in each Kamelet is a YAML flow, but a Kamelet can also hand-off processing to routes written in any of the other supported languages. E.g.

apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: java
  labels:
    camel.apache.org/kamelet.type: "source"
spec:
  sources:
  - content: |
      // camel-k: language=java

      import org.apache.camel.builder.RouteBuilder;

      public class Source extends RouteBuilder {
        @Override
        public void configure() throws Exception {

            from("direct:java")
              .setBody().exchangeProperty("prop1")
              .log("Prop is ${body}");

        }
      }
    name: Source.java
  definition:
    title: "Example of Kamelet with Java"
    description: "Passes data to Java"
    properties:
      prop1:
        title: Property 1
        description: A property
        type: string
        default: "The value"
  flow:
    # The template is always YAML, but it can pass work to Java
    from:
      uri: timer:tick
      steps:
        - set-property:
            name: "prop1"
            constant: "{{prop1}}"
        - to: "direct:java"
        - to: "kamelet:sink"

@arthurdm
Copy link
Author

thanks @nicolaferraro! Is there somewhere we could add this sample to?

@nicolaferraro
Copy link
Member

nicolaferraro commented Mar 15, 2021

thanks @nicolaferraro! Is there somewhere we could add this sample to?

There's a new developer's guide for Kamelets, maybe we can it as annex

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2021

This issue has been automatically marked as stale due to 90 days of inactivity.
It will be closed if no further activity occurs within 15 days.
If you think that’s incorrect or the issue should never stale, please simply write any comment.
Thanks for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants