public void stopSubscriber() {
        RequestHeader requestHeader = conversation.createRequestHeader(this.revisedCycleTime * 10);
        List<Long> subscriptions = Collections.singletonList(subscriptionId);
        DeleteSubscriptionsRequest deleteSubscriptionRequest = new DeleteSubscriptionsRequest(requestHeader, subscriptions);

        // subscription suspend can be invoked from multiple places, hence we manage transaction side of it
        RequestTransaction transaction = tm.startRequest();
        transaction.submit(() -> {
            //  Create Consumer for the response message, error and timeout to be sent to the Secure Channel
            conversation.submit(deleteSubscriptionRequest, DeleteSubscriptionsResponse.class)
                .thenAccept(responseMessage -> publishTask.cancel(true))
                .whenComplete((result, error) -> {
                    if (error != null) {
                        logger.error("Deletion of subscription resulted in error", error);
                        transaction.failRequest(error);
                    } else {
                        transaction.endRequest();
                    }
                    plcSubscriber.removeSubscription(subscriptionId);
                });
        });
    }
Stop the subscriber either on disconnect or on error
plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java