oscerd opened a new pull request, #23456: URL: https://github.com/apache/camel/pull/23456
## Motivation JIRA: https://issues.apache.org/jira/browse/CAMEL-23600 A user reported on the mailing list that the `camel-milo` OPC UA client works well for built-in OPC UA data types but cannot handle **custom (server-defined) data types**. Values of such nodes are returned as `ExtensionObject`, which can only be decoded — or, for writes, encoded — with an `EncodingContext` obtained from the underlying Eclipse Milo `OpcUaClient`. Today the `OpcUaClient` is held privately inside `SubscriptionManager.Connected` and is unreachable from outside the component, so users have no way to obtain the encoding contexts. ## Change Expose the active milo client through a new accessor: - `MiloClientConnection.getOpcUaClient()` — delegates through `SubscriptionManager` to the live `OpcUaClient` of the current connection. This is **purely additive**: no existing public API changes, no changed defaults, no new options. The component still does **not** auto-decode `ExtensionObject` values (it cannot reliably pick the right encoding context); instead it hands users the client so they can do it themselves: ```java MiloClientEndpoint endpoint = context.getEndpoint("milo-client:opc.tcp://localhost:4334", MiloClientEndpoint.class); MiloClientConnection connection = endpoint.createConnection(); try { OpcUaClient client = connection.getOpcUaClient(); EncodingContext ctx = client.getDynamicEncodingContext(); // dynamic = server-defined custom types UaStructuredType decoded = extensionObject.decode(ctx); // read path ExtensionObject toWrite = ExtensionObject.encode(ctx, myStructure); // write path } finally { endpoint.releaseConnection(connection); } ``` With the default caching connection manager, `createConnection()` returns the same connection the route uses, so this is the live client. ### Notes / contract - The connection is established lazily and asynchronously, so `getOpcUaClient()` returns `null` until connected, and again briefly during a reconnect. - The client is owned and managed by Camel; callers must not alter its lifecycle and should fetch it on demand rather than caching the reference (a reconnect replaces the instance). This is documented on the method and the component page. ## Testing - New `MiloClientOpcUaClientAccessTest` waits (Awaitility) for the connection, asserts the client and its encoding context are reachable, and performs an `ExtensionObject` encode/decode round-trip of a built-in structured type through the exposed context. - Full `camel-milo` module suite: 42 tests, 0 failures/errors. - `mvn formatter:format impsort:sort` applied. ## Docs - Added a "Custom data types: accessing the underlying milo OpcUaClient" section to `milo-client-component.adoc`. No upgrade-guide entry — the change is additive with no migration impact. --- _Generated by Claude Code on behalf of Andrea Cosentino (@oscerd)._ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
