public static void runServiceStartRoutines()

in services/library/src/main/java/com/google/cloud/pso/bq_snapshot_manager/helpers/Utils.java [91:115]


    public static void runServiceStartRoutines(LoggingHelper logger,
                                               TableOperationRequestResponse request,
                                               PersistentSet persistentSet,
                                               String persistentSetObjectPrefix,
                                               String trackingId
    ) throws NonRetryableApplicationException {
        logger.logFunctionStart(request.getTrackingId(), request.getTargetTable());
        logger.logInfoWithTracker(request.getTrackingId(),
                request.getTargetTable(),
                String.format("Request : %s", request.toString()));

        /**
         *  Check if we already processed this table before by this service to avoid submitting extra API requests
         *  in case we have duplicate PubSub messages. This is an extra measure to avoid unnecessary cost.
         *  We do that by keeping simple flag files in GCS with the pubSubMessageId as file name.
         */
        String flagFileName = String.format("%s/%s", persistentSetObjectPrefix, trackingId);
        if (persistentSet.contains(flagFileName)) {
            // log error and ACK and return
            String msg = String.format("tracking_id '%s' has been processed before by the service. This could be a PubSub duplicate message and safe to ignore or the previous messages were not ACK to PubSub to stop retries. Please investigate further if needed.",
                    trackingId
            );
            throw new NonRetryableApplicationException(msg);
        }
    }