etzel-mes commented on code in PR #28128:
URL: https://github.com/apache/camel/pull/28128#discussion_r4322872059
##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc:
##########
@@ -1806,6 +1806,24 @@ the server does not have, with the status code
`Bad_NodeIdUnknown`, and the othe
affected. Previously an awaited write or read completed without an error and
with a `null` body, and a browse failed
with a `NullPointerException`.
+=== camel-milo - the consumer reports a lost connection and refreshes its
values after it
+
+The OPC UA client consumer delivers `Bad_NoCommunication` with a null value
for every monitored node when
+communication with the server is lost, and the current value of every node
once communication is restored. Before,
+the consumer delivered nothing during an outage, and values that did not
change were not delivered again after it.
+
+A consumer that starts while the server cannot be reached, or whose client
cannot connect at all, for example because
+of wrong credentials or an untrusted server certificate, delivers the status
for its nodes too; the cause is in the
+log. A connection that Camel rebuilds after a failed request delivers it for
every node of the connection. Each loss and
+each recovery delivers one exchange per node.
+
+A route that uses only the value of the `DataValue` body receives a null for
these exchanges, which the type converters
+turn into `0` or `false`; a route that stores values checks the status code of
the body first, for example with
+`${body.statusCode.bad}`. A value can now arrive again after an outage, so a
route that counts values, computes
Review Comment:
Done in aee1e03ad75: the section now ends with a paragraph on keeping the
previous behaviour with `filter(simple("${body.statusCode.good}"))` right after
the consumer, noting that this also drops the other bad statuses and that the
current values delivered after an outage still arrive.
_Claude Code on behalf of etzel-mes_
##########
components/camel-milo/src/main/java/org/apache/camel/component/milo/client/internal/SubscriptionManager.java:
##########
@@ -115,25 +116,83 @@ public class SubscriptionManager {
StatusCodes.Bad_SecurityChecksFailed,
StatusCodes.Bad_TcpSecureChannelUnknown,
StatusCodes.Bad_RequestTypeInvalid);
+ /**
+ * The status of a monitored node while communication with the server is
lost: the source of the value is configured
+ * but cannot be reached, and no last value is kept (OPC 10000-8 Table 61,
OPC 10000-14 Table 80).
+ */
+ private static final StatusCode NO_COMMUNICATION = new
StatusCode(StatusCodes.Bad_NoCommunication);
+
private final AtomicLong clientHandleCounter = new AtomicLong();
+ /**
+ * The generation of the last connection built, zero before the first.
+ */
+ private final AtomicLong generationCounter = new AtomicLong();
+
/**
* Listens to the subscription of a connection and to the state of its
session. It is registered on the client
* before the client connects, so that it sees every change of the session
state.
*/
private final class SubscriptionListenerImpl
implements OpcUaSubscription.SubscriptionListener,
SessionActivityListener {
- private volatile boolean sessionActive;
+ /**
+ * The generation of the connection, which orders its values and loss
reports against those of the connection
+ * that replaces it.
+ */
+ private final long generation;
+
+ /**
+ * Whether the session is active. The client connects before the
connection is used, and Milo dispatches the
+ * activity callbacks in the order of the transitions.
+ */
+ private volatile boolean sessionActive = true;
+
+ /**
+ * The subscription of the connection, once it is created.
+ */
+ private volatile OpcUaSubscription subscription;
+
+ SubscriptionListenerImpl(final long generation) {
Review Comment:
Done in aee1e03ad75: the constructor now follows the `closed` and
`lostSessionId` fields. Both changes are folded into the first commit; the
branch keeps your rebase onto main.
_Claude Code on behalf of etzel-mes_
--
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]