You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "davsclaus (via GitHub)" <gi...@apache.org> on 2025/12/18 10:47:07 UTC
[PR] Once [camel]
davsclaus opened a new pull request, #20506:
URL: https://github.com/apache/camel/pull/20506
# Description
<!--
- Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
-->
# Target
- [ ] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch)
# Tracking
- [ ] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
<!--
# *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes.
-->
# Apache Camel coding standards and style
- [ ] I checked that each commit in the pull request has a meaningful subject line and body.
<!--
If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
-->
- [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes.
<!--
You can run the aforementioned command in your module so that the build auto-formats your code. This will also be verified as part of the checks and your PR may be rejected if if there are uncommited changes after running `mvn clean install -DskipTests`.
You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/CONTRIBUTING.md
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Once [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #20506:
URL: https://github.com/apache/camel/pull/20506
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Once [camel]
Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #20506:
URL: https://github.com/apache/camel/pull/20506#discussion_r2630924404
##########
components/camel-once/src/main/java/org/apache/camel/component/once/OnceEndpoint.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.once;
+
+import java.util.Map;
+
+import org.apache.camel.Category;
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+
+@UriEndpoint(firstVersion = "4.170.0", scheme = "once", title = "Once", syntax = "once:name", consumerOnly = true,
Review Comment:
typo 4.170.0 -> 4.17.0
##########
components/camel-once/src/main/java/org/apache/camel/component/once/OnceEndpoint.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.once;
+
+import java.util.Map;
+
+import org.apache.camel.Category;
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+
+@UriEndpoint(firstVersion = "4.170.0", scheme = "once", title = "Once", syntax = "once:name", consumerOnly = true,
+ remote = false, category = { Category.CORE, Category.SCHEDULING })
+public class OnceEndpoint extends DefaultEndpoint {
+
+ @UriPath
+ @Metadata(required = true)
+ private String name;
+ @UriParam(label = "advanced", defaultValue = "1000")
+ private long delay = 1000;
+ @UriParam
+ @Metadata(supportFileReference = true)
+ private String body;
+ @UriParam(multiValue = true, prefix = "header.")
+ @Metadata(supportFileReference = true)
+ private Map<String, String> headers;
+ @UriParam(label = "advanced", multiValue = true, prefix = "variable.")
+ @Metadata(supportFileReference = true)
+ private Map<String, String> variables;
+ @UriParam(label = "advanced", multiValue = true, prefix = "exchangeProperty.")
+ @Metadata(supportFileReference = true)
+ private Map<String, String> exchangeProperties;
+
+ public OnceEndpoint() {
+ }
+
+ public OnceEndpoint(String endpointUri, Component component, String name) {
+ super(endpointUri, component);
+ this.name = name;
+ }
+
+ @Override
+ public boolean isRemote() {
+ return false;
+ }
+
+ @Override
+ public OnceComponent getComponent() {
+ return (OnceComponent) super.getComponent();
+ }
+
+ @Override
+ public Producer createProducer() throws Exception {
+ throw new RuntimeCamelException("Cannot produce to a OnceEndpoint: " + getEndpointUri());
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ Consumer answer = new OnceConsumer(this, processor);
+ configureConsumer(answer);
+ return answer;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * The logical name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public long getDelay() {
+ return delay;
+ }
+
+ /**
+ * The number of milliseconds to wait before triggering.
+ * <p/>
+ * The default value is 1000.
Review Comment:
if I'm not mistaken, this is the parameter which can be set to -1 to fire as soon as possible, if yes, i think it is worthy to mention it in the javadoc (and so the catalog) directly too
##########
components/camel-once/src/main/java/org/apache/camel/component/once/OnceComponent.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.once;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.PropertiesHelper;
+
+@Component("once")
+public class OnceComponent extends DefaultComponent {
+
+ @Metadata(label = "advanced", defaultValue = "1000")
+ private long delay = 1000;
+
+ @Metadata(label = "advanced", defaultValue = "true")
+ private boolean languages = true;
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ OnceEndpoint answer = new OnceEndpoint(uri, this, remaining);
+ answer.setDelay(delay);
+
+ Map<String, String> headers = getAndRemoveOrResolveReferenceParameter(parameters, "headers", Map.class);
+ Map<String, Object> map = PropertiesHelper.extractProperties(parameters, "header.");
+ if (map != null && !map.isEmpty()) {
+ if (headers == null) {
+ headers = new LinkedHashMap<>();
+ }
+ for (Map.Entry<String, Object> me : map.entrySet()) {
+ headers.put(me.getKey(), me.getValue().toString());
+ }
+ }
+ if (headers != null && !headers.isEmpty()) {
+ answer.setHeaders(headers);
+ }
+ Map<String, String> variables = getAndRemoveOrResolveReferenceParameter(parameters, "variables", Map.class);
+ map = PropertiesHelper.extractProperties(parameters, "variable.");
+ if (map != null && !map.isEmpty()) {
+ if (variables == null) {
+ variables = new LinkedHashMap<>();
+ }
+ for (Map.Entry<String, Object> me : map.entrySet()) {
+ variables.put(me.getKey(), me.getValue().toString());
+ }
+ }
+ if (variables != null && !variables.isEmpty()) {
+ answer.setVariables(variables);
+ }
+ Map<String, String> properties = getAndRemoveOrResolveReferenceParameter(parameters, "exchangeProperties", Map.class);
+ map = PropertiesHelper.extractProperties(parameters, "exchangeProperty.");
+ if (map != null && !map.isEmpty()) {
+ if (properties == null) {
+ properties = new LinkedHashMap<>();
Review Comment:
what is the reason to use a LinkedHashMap instead of simple HashMap?
##########
components/camel-once/src/generated/resources/META-INF/org/apache/camel/component/once/once.json:
##########
@@ -0,0 +1,43 @@
+{
+ "component": {
+ "kind": "component",
+ "name": "once",
+ "title": "Once",
+ "description": "Camel Once component",
+ "deprecated": false,
+ "firstVersion": "4.170.0",
Review Comment:
typo 4.170.0 -> 4.17.0
##########
dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java:
##########
@@ -3553,6 +3553,19 @@ static Olingo2ComponentBuilderFactory.Olingo2ComponentBuilder olingo2() {
static Olingo4ComponentBuilderFactory.Olingo4ComponentBuilder olingo4() {
return Olingo4ComponentBuilderFactory.olingo4();
}
+ /**
+ * Once (camel-once)
+ * Camel Once component
+ *
+ * Category: core,scheduling
+ * Since: 4.170
Review Comment:
typo 4.170 -> 4.17
##########
components/camel-once/src/main/docs/once-component.adoc:
##########
@@ -0,0 +1,155 @@
+= Once Component
+:doctitle: Once
+:shortname: once
+:artifactid: camel-once
+:description: Camel Once component
+:since: 4.170
Review Comment:
typo 4.170 -> 4.17
##########
catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/once.json:
##########
@@ -0,0 +1,43 @@
+{
+ "component": {
+ "kind": "component",
+ "name": "once",
+ "title": "Once",
+ "description": "Camel Once component",
+ "deprecated": false,
+ "firstVersion": "4.170.0",
Review Comment:
typo here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Once [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20506:
URL: https://github.com/apache/camel/pull/20506#issuecomment-3669654633
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot.
* You can label PRs using `build-all`, `build-dependents`, `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the Summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
* :warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Once [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #20506:
URL: https://github.com/apache/camel/pull/20506#issuecomment-3670252533
thanks for spotting the typo et all - has been updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org