Claus Ibsen created CAMEL-27661:
-----------------------------------
Summary: camel-jmx: remote observedAttribute filter,
handback/notifyMatch ignored, metadata gaps
Key: CAMEL-27661
URL: https://issues.apache.org/jira/browse/CAMEL-27661
Project: Camel
Issue Type: Bug
Components: camel-jmx
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-jmx for CAMEL-23832
(commit
https://github.com/apache/camel/commit/a20e4e79e99c9ad48518fb74b552c8de4fec4756).
These are separate problems of the component; the descriptions commit only
documents the current behavior.
h4. 1. observedAttribute fails on a remote MBean server unless camel-jmx is on
the server's class path
With {{observedAttribute}} set and no {{notificationFilter}},
{{JMXConsumer.addNotificationListener()}} registers an
{{org.apache.camel.component.jmx.JMXConsumerNotificationFilter}}. For a remote
server, the JMX RMI connector wraps the filter in a {{MarshalledObject}}
({{RMIConnector.addNotificationListener()}}) and the server deserializes it
with its own class loaders and applies it
({{RMIConnectionImpl.addNotificationListeners()}}). If the remote JVM does not
have camel-jmx on its class path, the subscription fails when the consumer
starts. The tests do not show it, as their remote server runs in the same JVM.
Proposed change: for a remote server, register only a JDK filter (an
{{AttributeChangeNotificationFilter}} for the attribute) and compare
{{stringToCompare}} on the client, in {{JMXConsumer.handleNotification()}}.
h4. 2. The handback option is not used with monitorType
{{JMXMonitorConsumer.addNotificationListener()}} registers the listener on the
monitor MBean with the {{Monitor}} bean as the handback, so the
{{jmx.handback}} header holds the monitor and the {{handback}} option is
ignored.
Proposed change: pass {{ep.getHandback()}} when it is set, or keep the behavior
and reject or warn about the option with {{monitorType}}.
h4. 3. notifyMatch has no effect without monitorType
Without {{monitorType}}, {{JMXConsumer.addNotificationListener()}} builds the
filter with {{match = !ep.isNotifyDiffer()}}, so only {{notifyDiffer}} is read.
{{notifyMatch}} has the label {{consumer,string}}, which says it applies to the
plain consumer too. Setting both flags gives only the differing changes.
Proposed change: read both flags in the consumer filter, or change the label of
{{notifyMatch}} to {{string}}.
h4. 4. serverURL is not marked as required
The path option {{serverURL}} has no {{required = true}}, but the consumer
needs it: an empty value is not {{platform}}, so
{{JMXConsumer.initNetworkConnection()}} calls {{new JMXServiceURL("")}}, which
throws {{MalformedURLException}} at startup (or, with
{{testConnectionOnStartup=false}}, is retried every {{reconnectDelay}} seconds).
Proposed change: mark {{serverURL}} as required, and fail in
{{JMXComponent.createEndpoint()}} when it is empty.
h4. 5. initThreshold, offset and modulus have no defaultValue
These {{int}} options of {{JMXEndpoint}} use 0 when not set, but the metadata
has no {{defaultValue}}, so the docs show no default.
Proposed change: add {{defaultValue = "0"}}.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)