This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 331ab83d6bbc CAMEL-27612: camel-weather - poll once an hour, keep a 
user httpClient open, Hourly and Daily query the forecast (#30984)
331ab83d6bbc is described below

commit 331ab83d6bbc5bbd2365e2d69620d22b0f9b53cb
Author: allthingssecurity <[email protected]>
AuthorDate: Fri Nov 27 23:29:36 2026 +0530

    CAMEL-27612: camel-weather - poll once an hour, keep a user httpClient 
open, Hourly and Daily query the forecast (#30984)
    
    1. A weather consumer without a delay option polled every 500 ms:
       createConsumer() set the one hour delay on the consumer, and then
       ScheduledPollEndpoint.doConfigureConsumer() replaced it with its own 500 
ms
       default, as the delay of the endpoint was not set. The endpoint now has 
its
       own delay option with the one hour default and sets it in the 
constructor,
       as MailEndpoint and SlackEndpoint do, so the metadata (3600000) and the
       doc page agree with the code.
    
    2. WeatherEndpoint.doStop() closed the httpClient, also one that the user
       set and may share. The default client was created once in the field
       initializer of WeatherConfiguration, so an endpoint started again after a
       stop used a closed client. The endpoint now creates the default client in
       doInit() (the producer builds its query, which may call the geolocation
       provider, when it is created) and again in doStart() after a stop, and
       closes only the client it created.
    
    3. weatherApi Hourly and Daily without period queried the current weather.
       They now query the hourly or the daily forecast, with the length that
       OpenWeatherMap uses by default, also for a single ids value. Current and
       Station are unchanged: with period set, any value other than Hourly still
       gives the daily forecast.
    
    4. geolocationAccessKey and geolocationRequestHostIP are no longer marked
       required: they are used only when the location comes from the geolocation
       provider.
    
    5. The units comment in WeatherQuery said that metric is the default; 
without
       units OpenWeatherMap uses its standard units (Kelvin). The comment is
       fixed. WeatherUnits gets no STANDARD value, as leaving units unset 
already
       gives the standard units.
    
    Not changed: FeedEndpoint in camel-atom, which the ticket says may have the
    problem of point 1, is outside camel-weather.
    
    Regenerated weather.json (component and catalog copy), the endpoint
    configurer and the endpoint DSL. Upgrade guide entry for 4.24 for points 1,
    2 and 3.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../apache/camel/catalog/components/weather.json   |  12 +--
 .../weather/WeatherEndpointConfigurer.java         |   2 +-
 .../apache/camel/component/weather/weather.json    |  12 +--
 .../component/weather/WeatherConfiguration.java    |  17 ++-
 .../camel/component/weather/WeatherEndpoint.java   |  51 ++++++++-
 .../camel/component/weather/WeatherQuery.java      |  34 +++---
 .../weather/WeatherEndpointDefaultsTest.java       | 118 +++++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    |  14 +++
 .../dsl/WeatherEndpointBuilderFactory.java         |  76 ++++++++-----
 9 files changed, 266 insertions(+), 70 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/weather.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/weather.json
index 06aac3096b3c..8c2ec2713f64 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/weather.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/weather.json
@@ -44,9 +44,9 @@
     "headerName": { "index": 1, "kind": "parameter", "displayName": "Header 
Name", "group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The name of the header 
to store the response in, instead of the message body. The producer then leaves 
the body as [...]
     "language": { "index": 2, "kind": "parameter", "displayName": "Language", 
"group": "common", "label": "", "required": false, "type": "enum", "javaType": 
"org.apache.camel.component.weather.WeatherLanguage", "enum": [ "en", "ru", 
"it", "es", "sp", "uk", "ua", "de", "pt", "ro", "pl", "fi", "nl", "fr", "bg", 
"sv", "se", "zh_tw", "zh", "zh_cn", "tr", "hr", "ca" ], "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": "en", 
"configurationClass": "org.apache.camel.compo [...]
     "mode": { "index": 3, "kind": "parameter", "displayName": "Mode", "group": 
"common", "label": "", "required": false, "type": "enum", "javaType": 
"org.apache.camel.component.weather.WeatherMode", "enum": [ "HTML", "JSON", 
"XML" ], "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "JSON", "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The format of the 
response from OpenWeat [...]
-    "period": { "index": 4, "kind": "parameter", "displayName": "Period", 
"group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The length of a 
forecast, sent as the cnt query parameter: the number of days of the daily 
forecast, or the number of 3-hou [...]
+    "period": { "index": 4, "kind": "parameter", "displayName": "Period", 
"group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The length of a 
forecast, sent as the cnt query parameter: the number of days of the daily 
forecast, or the number of 3-hou [...]
     "units": { "index": 5, "kind": "parameter", "displayName": "Units", 
"group": "common", "label": "", "required": false, "type": "enum", "javaType": 
"org.apache.camel.component.weather.WeatherUnits", "enum": [ "IMPERIAL", 
"METRIC" ], "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The units of measurement 
in the response, for example of tempe [...]
-    "weatherApi": { "index": 6, "kind": "parameter", "displayName": "Weather 
Api", "group": "common", "label": "", "required": false, "type": "enum", 
"javaType": "org.apache.camel.component.weather.WeatherApi", "enum": [ 
"Current", "Station", "Hourly", "Daily" ], "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The OpenWeatherMap API 
to call. St [...]
+    "weatherApi": { "index": 6, "kind": "parameter", "displayName": "Weather 
Api", "group": "common", "label": "", "required": false, "type": "enum", 
"javaType": "org.apache.camel.component.weather.WeatherApi", "enum": [ 
"Current", "Station", "Hourly", "Daily" ], "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The OpenWeatherMap API 
to call. St [...]
     "sendEmptyMessageWhenIdle": { "index": 7, "kind": "parameter", 
"displayName": "Send Empty Message When Idle", "group": "consumer", "label": 
"consumer", "required": false, "type": "boolean", "javaType": "boolean", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 
false, "description": "If the polling consumer did not poll any files, you can 
enable this option to send an empty message (no body) instead." },
     "bridgeErrorHandler": { "index": 8, "kind": "parameter", "displayName": 
"Bridge Error Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Allows for bridging the consumer to the 
Camel routing Error Handler, which mean any exceptions (if possible) occurred 
while the Camel consumer is trying to pickup incoming  [...]
     "exceptionHandler": { "index": 9, "kind": "parameter", "displayName": 
"Exception Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", 
"deprecated": false, "autowired": false, "secret": false, "description": "To 
let the consumer use a custom ExceptionHandler. Notice if the option 
bridgeErrorHandler is enabled then this option is not in use. By def [...]
@@ -54,7 +54,7 @@
     "pollStrategy": { "index": 11, "kind": "parameter", "displayName": "Poll 
Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", 
"required": false, "type": "object", "javaType": 
"org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, 
"autowired": false, "secret": false, "description": "A pluggable 
org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your 
custom implementation to control error handling usually occurred during the po 
[...]
     "lazyStartProducer": { "index": 12, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produ [...]
     "geoLocationProvider": { "index": 13, "kind": "parameter", "displayName": 
"Geo Location Provider", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.component.weather.geolocation.GeoLocationProvider", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "A custom 
org.apache.camel.componen [...]
-    "httpClient": { "index": 14, "kind": "parameter", "displayName": "Http 
Client", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": 
"org.apache.hc.client5.http.impl.classic.CloseableHttpClient", "deprecated": 
false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "To use a custom 
org.apache.hc.client5.http.impl.classic.Clos [...]
+    "httpClient": { "index": 14, "kind": "parameter", "displayName": "Http 
Client", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": 
"org.apache.hc.client5.http.impl.classic.CloseableHttpClient", "deprecated": 
false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "To use a custom 
org.apache.hc.client5.http.impl.classic.Clos [...]
     "cnt": { "index": 15, "kind": "parameter", "displayName": "Cnt", "group": 
"filter", "label": "filter", "required": false, "type": "integer", "javaType": 
"java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The number of results, 
sent as the cnt query parameter, for example the number of cities or stations 
to find around lat  [...]
     "ids": { "index": 16, "kind": "parameter", "displayName": "Ids", "group": 
"filter", "label": "filter", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The ID of a city, or of 
a station with weatherApi Station, or a comma-separated list of city IDs to get 
the current weathe [...]
     "lat": { "index": 17, "kind": "parameter", "displayName": "Lat", "group": 
"filter", "label": "filter", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The latitude of the 
location, used together with lon, and taking precedence over the zip, ids and 
location options. For a  [...]
@@ -67,7 +67,7 @@
     "backoffErrorThreshold": { "index": 24, "kind": "parameter", 
"displayName": "Backoff Error Threshold", "group": "scheduler", "label": 
"consumer,scheduler", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
number of subsequent error polls (failed due some error) that should happen 
before the backoffMultipler should kick-in." },
     "backoffIdleThreshold": { "index": 25, "kind": "parameter", "displayName": 
"Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "The number of subsequent 
idle polls that should happen before the backoffMultipler should kick-in." },
     "backoffMultiplier": { "index": 26, "kind": "parameter", "displayName": 
"Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "To let the scheduled 
polling consumer backoff if there has been a number of subsequent idles\/errors 
in a row. The multiplier is then the number of polls that will be skipped 
before the next actual attempt is h [...]
-    "delay": { "index": 27, "kind": "parameter", "displayName": "Delay", 
"group": "scheduler", "label": "consumer,scheduler", "required": false, "type": 
"integer", "javaType": "long", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": 500, "description": "Milliseconds before the 
next poll." },
+    "delay": { "index": 27, "kind": "parameter", "displayName": "Delay", 
"group": "scheduler", "label": "consumer,scheduler", "required": false, "type": 
"duration", "javaType": "long", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": "3600000", "description": "Milliseconds before 
the next poll." },
     "greedy": { "index": 28, "kind": "parameter", "displayName": "Greedy", 
"group": "scheduler", "label": "consumer,scheduler", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "If greedy is enabled, 
then the ScheduledPollConsumer will run immediately again, if the previous run 
polled 1 or more messages." },
     "healthCheckMaxPollDuration": { "index": 29, "kind": "parameter", 
"displayName": "Health Check Max Poll Duration", "group": "scheduler", "label": 
"consumer,scheduler", "required": false, "type": "duration", "javaType": 
"long", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "0", "description": "How long a poll may run before the health 
check of the consumer reports DOWN. The health check is otherwise based on the 
polls that are done, so it stays UP while a p [...]
     "initialDelay": { "index": 30, "kind": "parameter", "displayName": 
"Initial Delay", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "long", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": 1000, "description": 
"Milliseconds before the first poll starts." },
@@ -80,7 +80,7 @@
     "timeUnit": { "index": 37, "kind": "parameter", "displayName": "Time 
Unit", "group": "scheduler", "label": "consumer,scheduler", "required": false, 
"type": "enum", "javaType": "java.util.concurrent.TimeUnit", "enum": [ 
"NANOSECONDS", "MICROSECONDS", "MILLISECONDS", "SECONDS", "MINUTES", "HOURS", 
"DAYS" ], "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "MILLISECONDS", "description": "Time unit for initialDelay and 
delay options." },
     "useFixedDelay": { "index": 38, "kind": "parameter", "displayName": "Use 
Fixed Delay", "group": "scheduler", "label": "consumer,scheduler", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in 
JDK for details." },
     "appid": { "index": 39, "kind": "parameter", "displayName": "Appid", 
"group": "security", "label": "security", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The API key of the 
OpenWeatherMap account, sent as the APPID query parameter of every request." },
-    "geolocationAccessKey": { "index": 40, "kind": "parameter", "displayName": 
"Geolocation Access Key", "group": "security", "label": "security", "required": 
true, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The access key of the 
ipstack API, which the default geoLocati [...]
-    "geolocationRequestHostIP": { "index": 41, "kind": "parameter", 
"displayName": "Geolocation Request Host IP", "group": "security", "label": 
"security", "required": true, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The IP address that the 
default geoLocationProvider looks up with the ipst [...]
+    "geolocationAccessKey": { "index": 40, "kind": "parameter", "displayName": 
"Geolocation Access Key", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The access key of the 
ipstack API, which the default geoLocat [...]
+    "geolocationRequestHostIP": { "index": 41, "kind": "parameter", 
"displayName": "Geolocation Request Host IP", "group": "security", "label": 
"security", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The IP address that the 
default geoLocationProvider looks up with the ips [...]
   }
 }
diff --git 
a/components/camel-weather/src/generated/java/org/apache/camel/component/weather/WeatherEndpointConfigurer.java
 
b/components/camel-weather/src/generated/java/org/apache/camel/component/weather/WeatherEndpointConfigurer.java
index 30d8ba7309d2..bdd8b4ca6035 100644
--- 
a/components/camel-weather/src/generated/java/org/apache/camel/component/weather/WeatherEndpointConfigurer.java
+++ 
b/components/camel-weather/src/generated/java/org/apache/camel/component/weather/WeatherEndpointConfigurer.java
@@ -34,7 +34,7 @@ public class WeatherEndpointConfigurer extends 
PropertyConfigurerSupport impleme
         case "bridgeerrorhandler":
         case "bridgeErrorHandler": 
target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); 
return true;
         case "cnt": target.getConfiguration().setCnt(property(camelContext, 
java.lang.Integer.class, value)); return true;
-        case "delay": target.setDelay(property(camelContext, long.class, 
value)); return true;
+        case "delay": target.setDelay(property(camelContext, 
java.time.Duration.class, value).toMillis()); return true;
         case "exceptionhandler":
         case "exceptionHandler": 
target.setExceptionHandler(property(camelContext, 
org.apache.camel.spi.ExceptionHandler.class, value)); return true;
         case "exchangepattern":
diff --git 
a/components/camel-weather/src/generated/resources/META-INF/org/apache/camel/component/weather/weather.json
 
b/components/camel-weather/src/generated/resources/META-INF/org/apache/camel/component/weather/weather.json
index 06aac3096b3c..8c2ec2713f64 100644
--- 
a/components/camel-weather/src/generated/resources/META-INF/org/apache/camel/component/weather/weather.json
+++ 
b/components/camel-weather/src/generated/resources/META-INF/org/apache/camel/component/weather/weather.json
@@ -44,9 +44,9 @@
     "headerName": { "index": 1, "kind": "parameter", "displayName": "Header 
Name", "group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The name of the header 
to store the response in, instead of the message body. The producer then leaves 
the body as [...]
     "language": { "index": 2, "kind": "parameter", "displayName": "Language", 
"group": "common", "label": "", "required": false, "type": "enum", "javaType": 
"org.apache.camel.component.weather.WeatherLanguage", "enum": [ "en", "ru", 
"it", "es", "sp", "uk", "ua", "de", "pt", "ro", "pl", "fi", "nl", "fr", "bg", 
"sv", "se", "zh_tw", "zh", "zh_cn", "tr", "hr", "ca" ], "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": "en", 
"configurationClass": "org.apache.camel.compo [...]
     "mode": { "index": 3, "kind": "parameter", "displayName": "Mode", "group": 
"common", "label": "", "required": false, "type": "enum", "javaType": 
"org.apache.camel.component.weather.WeatherMode", "enum": [ "HTML", "JSON", 
"XML" ], "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "JSON", "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The format of the 
response from OpenWeat [...]
-    "period": { "index": 4, "kind": "parameter", "displayName": "Period", 
"group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The length of a 
forecast, sent as the cnt query parameter: the number of days of the daily 
forecast, or the number of 3-hou [...]
+    "period": { "index": 4, "kind": "parameter", "displayName": "Period", 
"group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The length of a 
forecast, sent as the cnt query parameter: the number of days of the daily 
forecast, or the number of 3-hou [...]
     "units": { "index": 5, "kind": "parameter", "displayName": "Units", 
"group": "common", "label": "", "required": false, "type": "enum", "javaType": 
"org.apache.camel.component.weather.WeatherUnits", "enum": [ "IMPERIAL", 
"METRIC" ], "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The units of measurement 
in the response, for example of tempe [...]
-    "weatherApi": { "index": 6, "kind": "parameter", "displayName": "Weather 
Api", "group": "common", "label": "", "required": false, "type": "enum", 
"javaType": "org.apache.camel.component.weather.WeatherApi", "enum": [ 
"Current", "Station", "Hourly", "Daily" ], "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The OpenWeatherMap API 
to call. St [...]
+    "weatherApi": { "index": 6, "kind": "parameter", "displayName": "Weather 
Api", "group": "common", "label": "", "required": false, "type": "enum", 
"javaType": "org.apache.camel.component.weather.WeatherApi", "enum": [ 
"Current", "Station", "Hourly", "Daily" ], "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The OpenWeatherMap API 
to call. St [...]
     "sendEmptyMessageWhenIdle": { "index": 7, "kind": "parameter", 
"displayName": "Send Empty Message When Idle", "group": "consumer", "label": 
"consumer", "required": false, "type": "boolean", "javaType": "boolean", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 
false, "description": "If the polling consumer did not poll any files, you can 
enable this option to send an empty message (no body) instead." },
     "bridgeErrorHandler": { "index": 8, "kind": "parameter", "displayName": 
"Bridge Error Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Allows for bridging the consumer to the 
Camel routing Error Handler, which mean any exceptions (if possible) occurred 
while the Camel consumer is trying to pickup incoming  [...]
     "exceptionHandler": { "index": 9, "kind": "parameter", "displayName": 
"Exception Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", 
"deprecated": false, "autowired": false, "secret": false, "description": "To 
let the consumer use a custom ExceptionHandler. Notice if the option 
bridgeErrorHandler is enabled then this option is not in use. By def [...]
@@ -54,7 +54,7 @@
     "pollStrategy": { "index": 11, "kind": "parameter", "displayName": "Poll 
Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", 
"required": false, "type": "object", "javaType": 
"org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, 
"autowired": false, "secret": false, "description": "A pluggable 
org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your 
custom implementation to control error handling usually occurred during the po 
[...]
     "lazyStartProducer": { "index": 12, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produ [...]
     "geoLocationProvider": { "index": 13, "kind": "parameter", "displayName": 
"Geo Location Provider", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.component.weather.geolocation.GeoLocationProvider", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "A custom 
org.apache.camel.componen [...]
-    "httpClient": { "index": 14, "kind": "parameter", "displayName": "Http 
Client", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": 
"org.apache.hc.client5.http.impl.classic.CloseableHttpClient", "deprecated": 
false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "To use a custom 
org.apache.hc.client5.http.impl.classic.Clos [...]
+    "httpClient": { "index": 14, "kind": "parameter", "displayName": "Http 
Client", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": 
"org.apache.hc.client5.http.impl.classic.CloseableHttpClient", "deprecated": 
false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "To use a custom 
org.apache.hc.client5.http.impl.classic.Clos [...]
     "cnt": { "index": 15, "kind": "parameter", "displayName": "Cnt", "group": 
"filter", "label": "filter", "required": false, "type": "integer", "javaType": 
"java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The number of results, 
sent as the cnt query parameter, for example the number of cities or stations 
to find around lat  [...]
     "ids": { "index": 16, "kind": "parameter", "displayName": "Ids", "group": 
"filter", "label": "filter", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The ID of a city, or of 
a station with weatherApi Station, or a comma-separated list of city IDs to get 
the current weathe [...]
     "lat": { "index": 17, "kind": "parameter", "displayName": "Lat", "group": 
"filter", "label": "filter", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The latitude of the 
location, used together with lon, and taking precedence over the zip, ids and 
location options. For a  [...]
@@ -67,7 +67,7 @@
     "backoffErrorThreshold": { "index": 24, "kind": "parameter", 
"displayName": "Backoff Error Threshold", "group": "scheduler", "label": 
"consumer,scheduler", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
number of subsequent error polls (failed due some error) that should happen 
before the backoffMultipler should kick-in." },
     "backoffIdleThreshold": { "index": 25, "kind": "parameter", "displayName": 
"Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "The number of subsequent 
idle polls that should happen before the backoffMultipler should kick-in." },
     "backoffMultiplier": { "index": 26, "kind": "parameter", "displayName": 
"Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "To let the scheduled 
polling consumer backoff if there has been a number of subsequent idles\/errors 
in a row. The multiplier is then the number of polls that will be skipped 
before the next actual attempt is h [...]
-    "delay": { "index": 27, "kind": "parameter", "displayName": "Delay", 
"group": "scheduler", "label": "consumer,scheduler", "required": false, "type": 
"integer", "javaType": "long", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": 500, "description": "Milliseconds before the 
next poll." },
+    "delay": { "index": 27, "kind": "parameter", "displayName": "Delay", 
"group": "scheduler", "label": "consumer,scheduler", "required": false, "type": 
"duration", "javaType": "long", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": "3600000", "description": "Milliseconds before 
the next poll." },
     "greedy": { "index": 28, "kind": "parameter", "displayName": "Greedy", 
"group": "scheduler", "label": "consumer,scheduler", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "If greedy is enabled, 
then the ScheduledPollConsumer will run immediately again, if the previous run 
polled 1 or more messages." },
     "healthCheckMaxPollDuration": { "index": 29, "kind": "parameter", 
"displayName": "Health Check Max Poll Duration", "group": "scheduler", "label": 
"consumer,scheduler", "required": false, "type": "duration", "javaType": 
"long", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "0", "description": "How long a poll may run before the health 
check of the consumer reports DOWN. The health check is otherwise based on the 
polls that are done, so it stays UP while a p [...]
     "initialDelay": { "index": 30, "kind": "parameter", "displayName": 
"Initial Delay", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "long", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": 1000, "description": 
"Milliseconds before the first poll starts." },
@@ -80,7 +80,7 @@
     "timeUnit": { "index": 37, "kind": "parameter", "displayName": "Time 
Unit", "group": "scheduler", "label": "consumer,scheduler", "required": false, 
"type": "enum", "javaType": "java.util.concurrent.TimeUnit", "enum": [ 
"NANOSECONDS", "MICROSECONDS", "MILLISECONDS", "SECONDS", "MINUTES", "HOURS", 
"DAYS" ], "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "MILLISECONDS", "description": "Time unit for initialDelay and 
delay options." },
     "useFixedDelay": { "index": 38, "kind": "parameter", "displayName": "Use 
Fixed Delay", "group": "scheduler", "label": "consumer,scheduler", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in 
JDK for details." },
     "appid": { "index": 39, "kind": "parameter", "displayName": "Appid", 
"group": "security", "label": "security", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The API key of the 
OpenWeatherMap account, sent as the APPID query parameter of every request." },
-    "geolocationAccessKey": { "index": 40, "kind": "parameter", "displayName": 
"Geolocation Access Key", "group": "security", "label": "security", "required": 
true, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The access key of the 
ipstack API, which the default geoLocati [...]
-    "geolocationRequestHostIP": { "index": 41, "kind": "parameter", 
"displayName": "Geolocation Request Host IP", "group": "security", "label": 
"security", "required": true, "type": "string", "javaType": "java.lang.String", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The IP address that the 
default geoLocationProvider looks up with the ipst [...]
+    "geolocationAccessKey": { "index": 40, "kind": "parameter", "displayName": 
"Geolocation Access Key", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The access key of the 
ipstack API, which the default geoLocat [...]
+    "geolocationRequestHostIP": { "index": 41, "kind": "parameter", 
"displayName": "Geolocation Request Host IP", "group": "security", "label": 
"security", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"configurationClass": 
"org.apache.camel.component.weather.WeatherConfiguration", 
"configurationField": "configuration", "description": "The IP address that the 
default geoLocationProvider looks up with the ips [...]
   }
 }
diff --git 
a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
 
b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
index 15aec947f045..51ecc2a93ffd 100644
--- 
a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
+++ 
b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
@@ -26,7 +26,6 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.spi.UriPath;
 import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
-import org.apache.hc.client5.http.impl.classic.HttpClients;
 
 import static org.apache.camel.component.weather.WeatherLanguage.en;
 import static org.apache.camel.component.weather.WeatherMode.JSON;
@@ -44,8 +43,9 @@ public class WeatherConfiguration {
     private String appid;
     @UriParam(description = "The OpenWeatherMap API to call. Station queries 
weather stations instead of cities, for ids, "
                             + "for lat and lon with cnt, and for a bounding 
box. When period is set, Hourly gets the 3-hour "
-                            + "forecast and any other value, or none, the 
daily forecast; without period, Hourly and Daily get "
-                            + "the current weather.")
+                            + "forecast and any other value, or none, the 
daily forecast; without period, Hourly gets the 3-hour "
+                            + "forecast and Daily the daily forecast, with the 
length that OpenWeatherMap uses by default, and "
+                            + "any other value, or none, the current weather.")
     private WeatherApi weatherApi;
     @UriParam(description = "The city to get the weather for, by name and 
optionally a country code, for example London,uk. "
                             + "If empty or current, the latitude and longitude 
come from the geoLocationProvider. The lat and "
@@ -76,7 +76,8 @@ public class WeatherConfiguration {
     @UriParam(description = "The length of a forecast, sent as the cnt query 
parameter: the number of days of the daily "
                             + "forecast, or the number of 3-hour steps with 
weatherApi Hourly. Only the first number in the "
                             + "value is read, so 7 days is the same as 7, and 
a value with no number, or 0, is ignored. "
-                            + "If empty, the current weather is queried 
instead of a forecast.")
+                            + "If empty, the current weather is queried 
instead of a forecast, except with weatherApi Hourly "
+                            + "or Daily, which then get the forecast with the 
length that OpenWeatherMap uses by default.")
     private String period = "";
     @UriParam(description = "The format of the response from OpenWeatherMap: 
JSON, XML or HTML. XML and HTML are sent as the "
                             + "mode query parameter.",
@@ -109,20 +110,18 @@ public class WeatherConfiguration {
                             + "only when the location is looked up: location 
is empty or current, and none of lat and lon, zip "
                             + "or ids is set.",
               label = "security", security = "secret")
-    @Metadata(required = true)
     private String geolocationAccessKey;
     @UriParam(description = "The IP address that the default 
geoLocationProvider looks up with the ipstack API to find the "
                             + "latitude and longitude of the location. It is 
needed only when the location is looked up, as "
                             + "for geolocationAccessKey.",
               label = "security")
-    @Metadata(required = true)
     private String geolocationRequestHostIP;
     @UriParam(description = "To use a custom 
org.apache.hc.client5.http.impl.classic.CloseableHttpClient, for example one "
                             + "with an HTTP proxy, for the requests to 
OpenWeatherMap and to the default geoLocationProvider. "
-                            + "By default each endpoint creates its own 
client. The endpoint closes the client when it stops, "
-                            + "also a client that is set.",
+                            + "By default each endpoint creates its own 
client, closes it when it stops, and creates a new one "
+                            + "when it is started again. A client that is set 
is not closed by the endpoint.",
               label = "advanced")
-    private CloseableHttpClient httpClient = HttpClients.createDefault();
+    private CloseableHttpClient httpClient;
     @UriParam(description = "A custom 
org.apache.camel.component.weather.geolocation.GeoLocationProvider for the 
latitude "
                             + "and longitude of the location when location is 
empty or current, and none of lat and lon, zip "
                             + "or ids is set. The default looks up 
geolocationRequestHostIP with the ipstack API, and needs "
diff --git 
a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
 
b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
index 874f0c0cad6a..9645fc17a020 100644
--- 
a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
+++ 
b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java
@@ -28,6 +28,7 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultPollingEndpoint;
 import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
 
 /**
  * Query the current weather and weather forecasts from OpenWeatherMap.
@@ -48,15 +49,24 @@ import 
org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
                                                  + " unchanged"))
 public class WeatherEndpoint extends DefaultPollingEndpoint implements 
EndpointServiceLocation {
 
+    @UriParam(defaultValue = "" + WeatherConsumer.DEFAULT_CONSUMER_DELAY, 
javaType = "java.time.Duration",
+              label = "consumer,scheduler",
+              description = "Milliseconds before the next poll.")
+    private long delay = WeatherConsumer.DEFAULT_CONSUMER_DELAY;
+
     @UriParam
     private final WeatherConfiguration configuration;
 
     private final WeatherQuery weatherQuery;
+    private CloseableHttpClient createdHttpClient;
 
     public WeatherEndpoint(String uri, WeatherComponent component, 
WeatherConfiguration properties) {
         super(uri, component);
         this.configuration = properties;
         this.weatherQuery = new WeatherQuery(getConfiguration());
+        // ScheduledPollConsumer default delay is 500 millis and that is too 
often for polling the weather, so we
+        // override with a new default value. End user can override this value 
by providing a delay parameter
+        setDelay(WeatherConsumer.DEFAULT_CONSUMER_DELAY);
     }
 
     @Override
@@ -72,10 +82,6 @@ public class WeatherEndpoint extends DefaultPollingEndpoint 
implements EndpointS
     @Override
     public Consumer createConsumer(Processor processor) throws Exception {
         WeatherConsumer answer = new WeatherConsumer(this, processor);
-
-        // ScheduledPollConsumer default delay is 500 millis and that is too 
often for polling a feed, so we override
-        // with a new default value. End user can override this value by 
providing a consumer.delay parameter
-        answer.setDelay(WeatherConsumer.DEFAULT_CONSUMER_DELAY);
         configureConsumer(answer);
         return answer;
     }
@@ -93,12 +99,47 @@ public class WeatherEndpoint extends DefaultPollingEndpoint 
implements EndpointS
         return this.weatherQuery;
     }
 
+    /**
+     * Milliseconds before the next poll.
+     */
+    @Override
+    public void setDelay(long delay) {
+        super.setDelay(delay);
+        this.delay = delay;
+    }
+
+    @Override
+    protected void doInit() throws Exception {
+        super.doInit();
+        // the producer builds its query, which may call the geolocation 
provider, when it is created
+        createHttpClientIfNotSet();
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        // again after a stop, which closed the client the endpoint created
+        createHttpClientIfNotSet();
+    }
+
+    private void createHttpClientIfNotSet() {
+        if (getConfiguration().getHttpClient() == null) {
+            createdHttpClient = HttpClients.createDefault();
+            getConfiguration().setHttpClient(createdHttpClient);
+        }
+    }
+
     @Override
     protected void doStop() throws Exception {
         super.doStop();
 
-        CloseableHttpClient client = getConfiguration().getHttpClient();
+        // close only the client that the endpoint created: a client that is 
set may be shared
+        CloseableHttpClient client = createdHttpClient;
+        createdHttpClient = null;
         if (client != null) {
+            if (getConfiguration().getHttpClient() == client) {
+                getConfiguration().setHttpClient(null);
+            }
             client.close();
         }
     }
diff --git 
a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherQuery.java
 
b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherQuery.java
index d467f79da55f..8644a61c07af 100644
--- 
a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherQuery.java
+++ 
b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherQuery.java
@@ -76,7 +76,7 @@ public class WeatherQuery {
             answer += "&cnt=" + weatherConfiguration.getCnt();
         }
 
-        // append the desired measurement unit if not the default (which is 
metric)
+        // append the desired measurement unit, if set: without it 
OpenWeatherMap uses its standard units (Kelvin)
         if (weatherConfiguration.getUnits() != null) {
             answer += "&units=" + 
weatherConfiguration.getUnits().name().toLowerCase();
         }
@@ -109,12 +109,8 @@ public class WeatherQuery {
             }
         } else if (weatherConfiguration.getIds() != null && 
!weatherConfiguration.getIds().isEmpty()) {
             if (weatherConfiguration.getIdsAsList().size() == 1) {
-                if (!isEmpty(weatherConfiguration.getPeriod())) {
-                    if (weatherConfiguration.getWeatherApi() == 
WeatherApi.Hourly) {
-                        answer = "forecast?";
-                    } else {
-                        answer = "forecast/daily?";
-                    }
+                if (isForecast()) {
+                    answer = forecastContext();
                 } else if (weatherConfiguration.getWeatherApi() == 
WeatherApi.Station) {
                     answer = "station?";
                 } else {
@@ -123,18 +119,28 @@ public class WeatherQuery {
             } else {
                 answer = "group?";
             }
-        } else if (isEmpty(weatherConfiguration.getPeriod())) {
-            answer = "weather?";
+        } else if (isForecast()) {
+            answer = forecastContext();
         } else {
-            if (weatherConfiguration.getWeatherApi() == WeatherApi.Hourly) {
-                answer = "forecast?";
-            } else {
-                answer = "forecast/daily?";
-            }
+            answer = "weather?";
         }
         return answer;
     }
 
+    /**
+     * A forecast is queried with a period, or with weatherApi Hourly or 
Daily, which without a period get the forecast
+     * length that OpenWeatherMap uses by default.
+     */
+    private boolean isForecast() {
+        return !isEmpty(weatherConfiguration.getPeriod())
+                || weatherConfiguration.getWeatherApi() == WeatherApi.Hourly
+                || weatherConfiguration.getWeatherApi() == WeatherApi.Daily;
+    }
+
+    private String forecastContext() {
+        return weatherConfiguration.getWeatherApi() == WeatherApi.Hourly ? 
"forecast?" : "forecast/daily?";
+    }
+
     private static String createLatLonQueryString(String lat, String lon) {
         return "lat=" + lat + "&lon=" + lon;
     }
diff --git 
a/components/camel-weather/src/test/java/org/apache/camel/component/weather/WeatherEndpointDefaultsTest.java
 
b/components/camel-weather/src/test/java/org/apache/camel/component/weather/WeatherEndpointDefaultsTest.java
new file mode 100644
index 000000000000..9e31eabc0c56
--- /dev/null
+++ 
b/components/camel-weather/src/test/java/org/apache/camel/component/weather/WeatherEndpointDefaultsTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.weather;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.support.ScheduledPollConsumer;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
+/**
+ * The poll delay of the consumer, the http client of the endpoint, and the 
forecast queries of weatherApi, without
+ * calling OpenWeatherMap.
+ */
+class WeatherEndpointDefaultsTest extends CamelTestSupport {
+
+    private static final String URI = 
"weather:foo?location=Madrid,Spain&appid=x";
+
+    private long consumerDelay(String uri) throws Exception {
+        Consumer consumer = context.getEndpoint(uri).createConsumer(exchange 
-> {
+        });
+        return ((ScheduledPollConsumer) consumer).getDelay();
+    }
+
+    @Test
+    void consumerPollsOnceAnHourByDefault() throws Exception {
+        // the delay of the endpoint was not set, so the consumer got the 
default of 500 ms
+        assertEquals(WeatherConsumer.DEFAULT_CONSUMER_DELAY, 
consumerDelay(URI));
+    }
+
+    @Test
+    void delayOptionSetsTheConsumerDelay() throws Exception {
+        assertEquals(2000, consumerDelay(URI + "&delay=2000"));
+    }
+
+    @Test
+    void httpClientThatIsSetIsNotClosed() throws Exception {
+        CloseableHttpClient shared = mock(CloseableHttpClient.class);
+        context.getRegistry().bind("sharedClient", shared);
+        WeatherEndpoint endpoint = context.getEndpoint(URI + 
"&httpClient=#sharedClient", WeatherEndpoint.class);
+        endpoint.start();
+
+        endpoint.stop();
+
+        // the endpoint closed the client of its user, which other code may 
still use
+        verify(shared, never()).close();
+        assertSame(shared, endpoint.getConfiguration().getHttpClient());
+    }
+
+    @Test
+    void endpointStartedAgainHasAnOpenHttpClient() throws Exception {
+        WeatherEndpoint endpoint = context.getEndpoint(URI, 
WeatherEndpoint.class);
+        endpoint.start();
+        CloseableHttpClient first = 
endpoint.getConfiguration().getHttpClient();
+        assertNotNull(first);
+
+        endpoint.stop();
+        endpoint.start();
+
+        // the client was created once and closed on stop, so a restarted 
endpoint used a closed client
+        assertNotNull(endpoint.getConfiguration().getHttpClient());
+        assertNotSame(first, endpoint.getConfiguration().getHttpClient());
+    }
+
+    private static String query(WeatherApi api, String ids) throws Exception {
+        WeatherConfiguration configuration = new WeatherConfiguration();
+        configuration.setLocation("Madrid,Spain");
+        configuration.setWeatherApi(api);
+        if (ids != null) {
+            configuration.setIds(ids);
+        }
+        return new WeatherQuery(configuration).getQuery();
+    }
+
+    @Test
+    void hourlyWithoutPeriodQueriesTheHourlyForecast() throws Exception {
+        String query = query(WeatherApi.Hourly, null);
+
+        // the current weather was queried
+        
assertTrue(query.startsWith("http://api.openweathermap.org/data/2.5/forecast?q=";),
 query);
+        assertTrue(query(WeatherApi.Hourly, 
"524901").startsWith("http://api.openweathermap.org/data/2.5/forecast?id=";));
+    }
+
+    @Test
+    void dailyWithoutPeriodQueriesTheDailyForecast() throws Exception {
+        assertTrue(query(WeatherApi.Daily, 
null).startsWith("http://api.openweathermap.org/data/2.5/forecast/daily?q=";));
+        assertTrue(query(WeatherApi.Daily, 
"524901").startsWith("http://api.openweathermap.org/data/2.5/forecast/daily?id=";));
+    }
+
+    @Test
+    void currentWithoutPeriodQueriesTheCurrentWeather() throws Exception {
+        assertTrue(query(WeatherApi.Current, 
null).startsWith("http://api.openweathermap.org/data/2.5/weather?q=";));
+        assertTrue(query(null, 
null).startsWith("http://api.openweathermap.org/data/2.5/weather?q=";));
+    }
+}
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 76747c0b15de..842cdec20280 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -12393,6 +12393,20 @@ With `allowUrlBody=true`, a body that does not start 
with `version: 1` and is no
 with a space or a relative name, now fails with an `InvalidPayloadException`, 
as a URL with an unknown scheme already
 did. Before, it failed with an `IllegalArgumentException`. A URL that cannot 
be fetched keeps its own exception.
 
+=== camel-weather - the consumer polls once an hour, and weatherApi Hourly and 
Daily query the forecast
+
+A `weather` consumer without a `delay` option now polls once an hour, as its 
documentation says. The default delay of
+the scheduled poll consumer (500 milliseconds) replaced the one hour default 
before, so the consumer called
+OpenWeatherMap twice a second. Set `delay` to keep a shorter interval.
+
+`weatherApi=Hourly` and `weatherApi=Daily` without `period` now query the 
hourly or the daily forecast, with the length
+that OpenWeatherMap uses by default. Before, they queried the current weather. 
The daily forecast
+(`/data/2.5/forecast/daily`) needs a paid OpenWeatherMap subscription, so with 
a free API key `weatherApi=Daily` now
+fails with HTTP 401: use `weatherApi=Hourly`, or leave `weatherApi` unset for 
the current weather.
+
+A `weather` endpoint no longer closes an `httpClient` that is set on it when 
it stops; it closes only the client it
+created itself, and creates a new one when it is started again.
+
 === camel-printer - an unknown flavor or mimeType fails the endpoint
 
 An `lpr` endpoint now fails to be created when the `flavor` or the `mimeType` 
option has a value the component does not
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WeatherEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WeatherEndpointBuilderFactory.java
index 178891808efb..81a941d8546d 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WeatherEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WeatherEndpointBuilderFactory.java
@@ -132,7 +132,9 @@ public interface WeatherEndpointBuilderFactory {
          * of days of the daily forecast, or the number of 3-hour steps with
          * weatherApi Hourly. Only the first number in the value is read, so 7
          * days is the same as 7, and a value with no number, or 0, is ignored.
-         * If empty, the current weather is queried instead of a forecast.
+         * If empty, the current weather is queried instead of a forecast,
+         * except with weatherApi Hourly or Daily, which then get the forecast
+         * with the length that OpenWeatherMap uses by default.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
@@ -186,7 +188,9 @@ public interface WeatherEndpointBuilderFactory {
          * instead of cities, for ids, for lat and lon with cnt, and for a
          * bounding box. When period is set, Hourly gets the 3-hour forecast 
and
          * any other value, or none, the daily forecast; without period, Hourly
-         * and Daily get the current weather.
+         * gets the 3-hour forecast and Daily the daily forecast, with the
+         * length that OpenWeatherMap uses by default, and any other value, or
+         * none, the current weather.
          * 
          * The option is a:
          * <code>org.apache.camel.component.weather.WeatherApi</code> type.
@@ -205,7 +209,9 @@ public interface WeatherEndpointBuilderFactory {
          * instead of cities, for ids, for lat and lon with cnt, and for a
          * bounding box. When period is set, Hourly gets the 3-hour forecast 
and
          * any other value, or none, the daily forecast; without period, Hourly
-         * and Daily get the current weather.
+         * gets the 3-hour forecast and Daily the daily forecast, with the
+         * length that OpenWeatherMap uses by default, and any other value, or
+         * none, the current weather.
          * 
          * The option will be converted to a
          * <code>org.apache.camel.component.weather.WeatherApi</code> type.
@@ -533,7 +539,7 @@ public interface WeatherEndpointBuilderFactory {
          * 
          * The option is a: <code>long</code> type.
          * 
-         * Default: 500
+         * Default: 3600000
          * Group: scheduler
          * 
          * @param delay the value to set
@@ -548,7 +554,7 @@ public interface WeatherEndpointBuilderFactory {
          * 
          * The option will be converted to a <code>long</code> type.
          * 
-         * Default: 500
+         * Default: 3600000
          * Group: scheduler
          * 
          * @param delay the value to set
@@ -953,7 +959,6 @@ public interface WeatherEndpointBuilderFactory {
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
-         * Required: true
          * Group: security
          * 
          * @param geolocationAccessKey the value to set
@@ -971,7 +976,6 @@ public interface WeatherEndpointBuilderFactory {
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
-         * Required: true
          * Group: security
          * 
          * @param geolocationRequestHostIP the value to set
@@ -1190,8 +1194,9 @@ public interface WeatherEndpointBuilderFactory {
          * org.apache.hc.client5.http.impl.classic.CloseableHttpClient, for
          * example one with an HTTP proxy, for the requests to OpenWeatherMap
          * and to the default geoLocationProvider. By default each endpoint
-         * creates its own client. The endpoint closes the client when it 
stops,
-         * also a client that is set.
+         * creates its own client, closes it when it stops, and creates a new
+         * one when it is started again. A client that is set is not closed by
+         * the endpoint.
          * 
          * The option is a:
          * 
<code>org.apache.hc.client5.http.impl.classic.CloseableHttpClient</code> type.
@@ -1210,8 +1215,9 @@ public interface WeatherEndpointBuilderFactory {
          * org.apache.hc.client5.http.impl.classic.CloseableHttpClient, for
          * example one with an HTTP proxy, for the requests to OpenWeatherMap
          * and to the default geoLocationProvider. By default each endpoint
-         * creates its own client. The endpoint closes the client when it 
stops,
-         * also a client that is set.
+         * creates its own client, closes it when it stops, and creates a new
+         * one when it is started again. A client that is set is not closed by
+         * the endpoint.
          * 
          * The option will be converted to a
          * 
<code>org.apache.hc.client5.http.impl.classic.CloseableHttpClient</code> type.
@@ -1326,7 +1332,9 @@ public interface WeatherEndpointBuilderFactory {
          * of days of the daily forecast, or the number of 3-hour steps with
          * weatherApi Hourly. Only the first number in the value is read, so 7
          * days is the same as 7, and a value with no number, or 0, is ignored.
-         * If empty, the current weather is queried instead of a forecast.
+         * If empty, the current weather is queried instead of a forecast,
+         * except with weatherApi Hourly or Daily, which then get the forecast
+         * with the length that OpenWeatherMap uses by default.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
@@ -1380,7 +1388,9 @@ public interface WeatherEndpointBuilderFactory {
          * instead of cities, for ids, for lat and lon with cnt, and for a
          * bounding box. When period is set, Hourly gets the 3-hour forecast 
and
          * any other value, or none, the daily forecast; without period, Hourly
-         * and Daily get the current weather.
+         * gets the 3-hour forecast and Daily the daily forecast, with the
+         * length that OpenWeatherMap uses by default, and any other value, or
+         * none, the current weather.
          * 
          * The option is a:
          * <code>org.apache.camel.component.weather.WeatherApi</code> type.
@@ -1399,7 +1409,9 @@ public interface WeatherEndpointBuilderFactory {
          * instead of cities, for ids, for lat and lon with cnt, and for a
          * bounding box. When period is set, Hourly gets the 3-hour forecast 
and
          * any other value, or none, the daily forecast; without period, Hourly
-         * and Daily get the current weather.
+         * gets the 3-hour forecast and Daily the daily forecast, with the
+         * length that OpenWeatherMap uses by default, and any other value, or
+         * none, the current weather.
          * 
          * The option will be converted to a
          * <code>org.apache.camel.component.weather.WeatherApi</code> type.
@@ -1616,7 +1628,6 @@ public interface WeatherEndpointBuilderFactory {
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
-         * Required: true
          * Group: security
          * 
          * @param geolocationAccessKey the value to set
@@ -1634,7 +1645,6 @@ public interface WeatherEndpointBuilderFactory {
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
-         * Required: true
          * Group: security
          * 
          * @param geolocationRequestHostIP the value to set
@@ -1745,8 +1755,9 @@ public interface WeatherEndpointBuilderFactory {
          * org.apache.hc.client5.http.impl.classic.CloseableHttpClient, for
          * example one with an HTTP proxy, for the requests to OpenWeatherMap
          * and to the default geoLocationProvider. By default each endpoint
-         * creates its own client. The endpoint closes the client when it 
stops,
-         * also a client that is set.
+         * creates its own client, closes it when it stops, and creates a new
+         * one when it is started again. A client that is set is not closed by
+         * the endpoint.
          * 
          * The option is a:
          * 
<code>org.apache.hc.client5.http.impl.classic.CloseableHttpClient</code> type.
@@ -1765,8 +1776,9 @@ public interface WeatherEndpointBuilderFactory {
          * org.apache.hc.client5.http.impl.classic.CloseableHttpClient, for
          * example one with an HTTP proxy, for the requests to OpenWeatherMap
          * and to the default geoLocationProvider. By default each endpoint
-         * creates its own client. The endpoint closes the client when it 
stops,
-         * also a client that is set.
+         * creates its own client, closes it when it stops, and creates a new
+         * one when it is started again. A client that is set is not closed by
+         * the endpoint.
          * 
          * The option will be converted to a
          * 
<code>org.apache.hc.client5.http.impl.classic.CloseableHttpClient</code> type.
@@ -1882,7 +1894,9 @@ public interface WeatherEndpointBuilderFactory {
          * of days of the daily forecast, or the number of 3-hour steps with
          * weatherApi Hourly. Only the first number in the value is read, so 7
          * days is the same as 7, and a value with no number, or 0, is ignored.
-         * If empty, the current weather is queried instead of a forecast.
+         * If empty, the current weather is queried instead of a forecast,
+         * except with weatherApi Hourly or Daily, which then get the forecast
+         * with the length that OpenWeatherMap uses by default.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
@@ -1936,7 +1950,9 @@ public interface WeatherEndpointBuilderFactory {
          * instead of cities, for ids, for lat and lon with cnt, and for a
          * bounding box. When period is set, Hourly gets the 3-hour forecast 
and
          * any other value, or none, the daily forecast; without period, Hourly
-         * and Daily get the current weather.
+         * gets the 3-hour forecast and Daily the daily forecast, with the
+         * length that OpenWeatherMap uses by default, and any other value, or
+         * none, the current weather.
          * 
          * The option is a:
          * <code>org.apache.camel.component.weather.WeatherApi</code> type.
@@ -1955,7 +1971,9 @@ public interface WeatherEndpointBuilderFactory {
          * instead of cities, for ids, for lat and lon with cnt, and for a
          * bounding box. When period is set, Hourly gets the 3-hour forecast 
and
          * any other value, or none, the daily forecast; without period, Hourly
-         * and Daily get the current weather.
+         * gets the 3-hour forecast and Daily the daily forecast, with the
+         * length that OpenWeatherMap uses by default, and any other value, or
+         * none, the current weather.
          * 
          * The option will be converted to a
          * <code>org.apache.camel.component.weather.WeatherApi</code> type.
@@ -2172,7 +2190,6 @@ public interface WeatherEndpointBuilderFactory {
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
-         * Required: true
          * Group: security
          * 
          * @param geolocationAccessKey the value to set
@@ -2190,7 +2207,6 @@ public interface WeatherEndpointBuilderFactory {
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
-         * Required: true
          * Group: security
          * 
          * @param geolocationRequestHostIP the value to set
@@ -2258,8 +2274,9 @@ public interface WeatherEndpointBuilderFactory {
          * org.apache.hc.client5.http.impl.classic.CloseableHttpClient, for
          * example one with an HTTP proxy, for the requests to OpenWeatherMap
          * and to the default geoLocationProvider. By default each endpoint
-         * creates its own client. The endpoint closes the client when it 
stops,
-         * also a client that is set.
+         * creates its own client, closes it when it stops, and creates a new
+         * one when it is started again. A client that is set is not closed by
+         * the endpoint.
          * 
          * The option is a:
          * 
<code>org.apache.hc.client5.http.impl.classic.CloseableHttpClient</code> type.
@@ -2278,8 +2295,9 @@ public interface WeatherEndpointBuilderFactory {
          * org.apache.hc.client5.http.impl.classic.CloseableHttpClient, for
          * example one with an HTTP proxy, for the requests to OpenWeatherMap
          * and to the default geoLocationProvider. By default each endpoint
-         * creates its own client. The endpoint closes the client when it 
stops,
-         * also a client that is set.
+         * creates its own client, closes it when it stops, and creates a new
+         * one when it is started again. A client that is set is not closed by
+         * the endpoint.
          * 
          * The option will be converted to a
          * 
<code>org.apache.hc.client5.http.impl.classic.CloseableHttpClient</code> type.

Reply via email to