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

Bean reference and processors seem to be non-existent #736

Closed
dbaggett opened this issue Jan 25, 2022 · 11 comments
Closed

Bean reference and processors seem to be non-existent #736

dbaggett opened this issue Jan 25, 2022 · 11 comments

Comments

@dbaggett
Copy link

It appears that references to beans and processor EIP are not a thing in kamelets. I think the reasons are pretty obvious given it's difficult to do custom logic in a static yaml template. I just want to make sure I am not missing something. Is there an idiomatic way to do custom processing in a kamelet. For example, multicast to multiple http endpoint and aggregating JSON from each respective response is a pattern I've used frequently. How could I replicate this in a kamelet?

@oscerd
Copy link
Contributor

oscerd commented Jan 25, 2022

Hello and thanks for the interest in camel-kamelets and Apache Camel in general.

In pure Kamelet is really hard to add custom logic like bean, but you can always write your own kamelet without troubles. For example you could something like this:
https://github.com/apache/camel-kamelets/blob/main/kamelets/extract-field-action.kamelet.yaml#L106

This is a way of calling a bean inside the Kamelet body, but I do think you're thinking about calling something like

from kamelet-source
steps
kamelet-bean
to kamelet-sink

and this is not possible currently and I think in the future too.

The aim of Kamelets is abstracting the Apache Camel technical details by hiding them into logical unit, like a pre-baked endpoint, like a Kamelet is.

You could always create a yaml route using the camel-kamelet components, like for example:

- route:
    from:
      uri: "kamelet:aws-s3-source"
      parameters:
        accesKey: "peppe"
        secretKey: "peppe"
        region: "eu-west-1"
        bucketNameOrArn: "camel-kafka-connector"
        useDefaultCredentialsProvider: "true"
      steps:
        - bean: "org.apache.camel.kamelets.utils.transform.ExtractField"
        - to:
            uri: "kamelet:log-sink"
            parameters:
              showHeaders: "true"

In yaml you'll have all the related definition from plain Camel

https://github.com/apache/camel/blob/main/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json#L1650

https://github.com/apache/camel/blob/main/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json#L446

In case you need to do something complex, my suggestion is using camel-kamelet component as the example above, mixed with the Yaml construct available.

HTH a bit.

@oscerd
Copy link
Contributor

oscerd commented Jan 25, 2022

Let me know if this answer your question.

@dbaggett
Copy link
Author

This is getting me closer than before, so yes, big help indeed. I am still a little fuzzy on how to pull all this together though. Would it be possible to see the definition for "org.apache.camel.kamelets.utils.transform.ExtractField". It's not quite clear how you would define that with yaml. Also, what steps would you need to take to make the bean available in your own flow? Please forgive me if this is documented somewhere.

@dbaggett
Copy link
Author

Ok picture is clearer now, I found it https://github.com/apache/camel-kamelets/blob/0.5.x/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/ExtractField.java. Part of my previous question remains, how would you make a custom bean like this available in the k8s environment.

@oscerd
Copy link
Contributor

oscerd commented Jan 25, 2022

You need to pack it in a dependency, like jitpack or a maven one and reference it in your project.

You're using camel-k right?

@dbaggett
Copy link
Author

Yes, new camel-k user here. I see and that's where https://camel.apache.org/camel-k/1.7.x/configuration/dependencies.html would come in. I assume there's not a more "direct" way to make that dependency available atm?

@oscerd
Copy link
Contributor

oscerd commented Jan 26, 2022

In the past, for camel-k, you were able to pass multiple java/yaml/xml file, while running your integration with kamel run, this behavior has been updated at some point: apache/camel-k#1821

So, no, there is no more "direct" way.

@dbaggett
Copy link
Author

@oscerd thanks for all the information! I'll be closing this issue, but I do have one more question, if you don't mind. What does all this mean for bean reference support in Camel K. How would one handle strategy references on the enrich or aggregate EIPs for example?

@oscerd
Copy link
Contributor

oscerd commented Jan 31, 2022

You can pack all of your strategies into a jar and place it on jitpack or on a private nexus or maven central and add them to your camel-k project as depedency.

@dbaggett
Copy link
Author

Ok, makes sense. Thank you for the help.

@oscerd
Copy link
Contributor

oscerd commented Jan 31, 2022

Thanks a lot for your feedback and please, if you have questions or find something weird, just open an issues. Kamelet and camel-k are still under heavy development.

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

No branches or pull requests

2 participants