[ 
https://issues.apache.org/jira/browse/CAMEL-27612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved CAMEL-27612.
---------------------------------
    Resolution: Fixed

Merged with https://github.com/apache/camel/pull/30984 as 331ab83d6bbc on main 
(4.24.0).

_Claude Code on behalf of Claus Ibsen_

> camel-weather: consumer polls every 500 ms, httpClient closed on stop, 
> weatherApi, metadata
> -------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27612
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27612
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-weather
>            Reporter: Claus Ibsen
>            Assignee: shashank
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Found while improving the option descriptions of camel-weather for 
> CAMEL-23832 (PR https://github.com/apache/camel/pull/30948).
> These are separate problems of the component; the descriptions PR only 
> documents the current behavior.
> h4. 1. The consumer polls every 500 ms instead of once an hour
> {{WeatherEndpoint.createConsumer()}} sets the delay to 
> {{WeatherConsumer.DEFAULT_CONSUMER_DELAY}} (one hour) and then calls 
> {{configureConsumer(answer)}}.
> {{ScheduledPollEndpoint.doConfigureConsumer()}} then sees that the endpoint 
> {{delay}} option is not set (-1), and sets the delay of the consumer to its 
> own default of 500 ms.
> So a weather consumer without a {{delay}} option calls OpenWeatherMap twice a 
> second, while the doc page says it polls once per hour.
> The metadata gives the {{delay}} default as 500, which is what happens now, 
> but not what the component intends.
> Proposed change: set the one-hour default on the endpoint (as 
> {{MailEndpoint}} does with {{setDelay(...)}} and its own {{delay}} 
> {{@UriParam}} with that {{defaultValue}}), so that the metadata and the doc 
> page agree with the code.
> {{FeedEndpoint.createConsumer()}} in camel-atom uses the same pattern and may 
> have the same problem.
> h4. 2. The endpoint closes the httpClient on stop, also a client that the 
> user set
> {{WeatherEndpoint.doStop()}} closes {{getConfiguration().getHttpClient()}}.
> When the user sets {{httpClient}} to a client that is shared with other code 
> or other endpoints, stopping one weather endpoint closes the client for all 
> of them.
> The default client is created once, in the field initializer of 
> {{WeatherConfiguration}}, so an endpoint that is started again after a stop 
> uses a closed client.
> Proposed change: close only the client that the endpoint created, and create 
> it in {{doStart()}}.
> h4. 3. weatherApi Hourly and Daily have no effect without period, and Current 
> is never read
> {{WeatherQuery.createContext()}} checks only {{WeatherApi.Hourly}} and 
> {{WeatherApi.Station}}.
> Without {{period}}, {{weatherApi=Hourly}} or {{weatherApi=Daily}} still calls 
> {{weather?}} and returns the current weather, with no warning.
> {{WeatherApi.Current}} and {{WeatherApi.Daily}} are not referenced anywhere 
> in the code: with {{period}} set, any value other than Hourly gives the daily 
> forecast.
> Proposed change: make Hourly and Daily query the forecast (with a default 
> length), or reject them without {{period}}.
> h4. 4. geolocationAccessKey and geolocationRequestHostIP are marked required
> {{WeatherConfiguration}} has {{@Metadata(required = true)}} on both options.
> They are used only by 
> {{FreeGeoIpGeoLocationProvider.getCurrentGeoLocation()}}, which 
> {{WeatherQuery.getQuery()}} calls only when {{location}} is empty or 
> {{current}} and none of {{lat}} and {{lon}}, {{zip}} or {{ids}} is set.
> Tools that read the catalog (for example a visual route editor) ask for both 
> values on every weather endpoint.
> Proposed change: remove {{required = true}} from both options.
> h4. 5. The units comment in WeatherQuery is wrong, and WeatherUnits has no 
> STANDARD value
> {{WeatherQuery.getQuery()}} has the comment "append the desired measurement 
> unit if not the default (which is metric)".
> OpenWeatherMap uses standard units (temperature in Kelvin) when no {{units}} 
> parameter is sent, and {{WeatherUnits}} has only {{IMPERIAL}} and {{METRIC}}.
> Proposed change: fix the comment, and consider adding {{STANDARD}} to 
> {{WeatherUnits}}.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to