-
Notifications
You must be signed in to change notification settings - Fork 5.1k
CAMEL-22292: Add --infra option to camel cmd send for infrastructure services #20767
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
Conversation
|
Hi @pkalsi97 thanks for the PR, this is really interesting. By any chance did you test all the infrastructure? Some time ago I did an alignment of the infra properties (the key you can find in the json), with the component's properties, therefore, the mapping should work automatically, it should be safe to use jsons properties as key/values in the command. But I am not 100% sure it will work for all the usecases. |
...bang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
Outdated
Show resolved
Hide resolved
|
You need to use Where map is a map with key/value pairs. This will build the uri correct according to the given component. |
|
Hey ! @Croway @davsclaus First of all apologies, i could have tackled this issue better by first discussing the approach and solution in the issue itself before lodging the PR. I got way to excited haha. Thank a lot for your inputs i'll incorporate these in the followup. Regarding the --infra option coverage, this got way to overlooked in the PR. I am fairly determined to cover all services, what testing approach is expected? Will Unit test (Mock the JSON for each service -> Verify the generated endpoint URI) will that be sufficient? |
|
@pkalsi97 no worries! moreover, I like the idea yeah, mocking the JSON sounds good, this way we won't have to to download all the images on the CI. We have to make sure that all the properties in the test-infra services like https://github.com/apache/camel/blob/main/test-infra/camel-test-infra-kafka/src/main/java/org/apache/camel/test/infra/kafka/services/KafkaInfraService.java are either supported by the component as is (brokers in this case), or somehow handled, in this case |
|
We can remove the deprecated options so this tool wont see "bad" options. |
|
@Croway and @davsclaus Thanks a lot for the inputs. I have implemented some refinements based on the feedback
|
|
After a bit more digging it looks like not all cases in the test are setup correctly, i'll work on fixing it. I should have manually run every infra to validate my test cases with the actual. In some infra services turn out the test is validating if the properties exist but did not validate that the Camel component actually accepts those properties. |
...bang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
Outdated
Show resolved
Hide resolved
|
How is it going here ? |
|
@davsclaus Hey! its going great @Croway filled me on the right approach, i am working on it and will try to push a better implementation shortly. |
|
@Croway I have made a lot of changes based on your suggestion. I still don't think the work is complete as i am yet to manually test all infra against the command. Please review the current implementation and let me know if i am going in the right direction. |
...bang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
Outdated
Show resolved
Hide resolved
...bang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
Outdated
Show resolved
Hide resolved
|
Hi @pkalsi97 almost there! I left a couple of comments, thanks |
|
@Croway Thanks! i have removed the workarounds. |
|
|
||
| private String buildPathBasedEndpoint(String path, JsonObject connectionDetails) { | ||
|
|
||
| Object endpointUri = connectionDetails.get("endpointUri"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented this method to handle infra like FTP, SMB, ZooKeeper etc where the connection details (host:port) and the target resource file path are fused into a single URI eg ftp://localhost:2121/myDir
If a user tries to override the target path, i came to an understanding that we would have no clean way to retain the host/port, we would loose the connection. This method safely appends the user's requested path and ensures we can switch targets dynamically without loosing the correct infra connection settings.
...bang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java
Outdated
Show resolved
Hide resolved
| private Map<String, String> buildBeanProperties(JsonObject connectionDetails) { | ||
| Map<String, String> properties = new LinkedHashMap<>(); | ||
|
|
||
| Object beanProps = connectionDetails.get("beanProperties"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was specially added to support Postgres and OpenLDAP, at least from my understanding the endpoint URI specifically refers to a named bean and since these beans aren't part of the component's schema they would be filtered out by the catalog logic.
buildBeanProperties method bridges that gap by extracting these bean definitions from the infra JSON and passing them to the Camel Main instance, ensuring the components have the dependencies they need to run.
|
Thanks @pkalsi97, I left few more comments, if the special handling for these properties are really needed (and it is not a workaround), I think we can merge as is |
|
@Croway Thanks for the inputs and pointing out the flaws in implementations, i really picked up this issues hoping it would be a simple implementation but turn out this involved developing an understanding about all the supported infra. If you have better suggestions regarding anything please let me know. i would be more than happy to implement or improve the current implementation. |
|
@pkalsi97 looking good, I am going to merge it as soon as the CI is green. Thank you! |
|
Great work. The doc says Camel 4.17 but this will make it into 4.18 |
Description
This PR adds a feature to the
camel cmd sendcommand to support sending messages directly to infrastructure services (like NATS, Kafka, Redis, etc.) that are started withcamel infra runand updated docs.Previously, users had to manually specify server connection details, but now the command automatically reads connection information from JSON files created by infrastructure services.
How it works:
--infraoption is specified, we locate the corresponding infra service JSON file.Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.