private static void doCommonChecks(FunctionConfig functionConfig) { Collection<String> allInputTopics = collectAllInputTopics(functionConfig); if (allInputTopics.isEmpty()) { throw new RuntimeException("No input topic(s) specified for the function"); } // Ensure that topics aren't being used as both input and output verifyNoTopicClash(allInputTopics, functionConfig.getOutput()); WindowConfig windowConfig = functionConfig.getWindowConfig(); if (windowConfig != null) { // set auto ack to false since windowing framework is responsible // for acking and not the function framework if (functionConfig.isAutoAck() == true) { throw new IllegalArgumentException("Cannot enable auto ack when using windowing functionality"); } functionConfig.setAutoAck(false); } if (functionConfig.getTimeoutMs() != null && functionConfig.getProcessingGuarantees() != null && functionConfig.getProcessingGuarantees() != FunctionConfig.ProcessingGuarantees.ATLEAST_ONCE) { throw new IllegalArgumentException("Message timeout can only be specified with processing guarantee is " + FunctionConfig.ProcessingGuarantees.ATLEAST_ONCE.name()); } if (functionConfig.getMaxMessageRetries() >= 0 && functionConfig.getProcessingGuarantees() == FunctionConfig.ProcessingGuarantees.EFFECTIVELY_ONCE) { throw new IllegalArgumentException("MaxMessageRetries and Effectively once don't gel well"); } if (functionConfig.getMaxMessageRetries() < 0 && !StringUtils.isEmpty(functionConfig.getDeadLetterTopic())) { throw new IllegalArgumentException("Dead Letter Topic specified, however max retries is set to infinity"); } }
private void inferMissingArguments(FunctionConfig functionConfig) { if (StringUtils.isEmpty(functionConfig.getName())) { inferMissingFunctionName(functionConfig); } if (StringUtils.isEmpty(functionConfig.getTenant())) { inferMissingTenant(functionConfig); } if (StringUtils.isEmpty(functionConfig.getNamespace())) { inferMissingNamespace(functionConfig); } if (functionConfig.getParallelism() == 0) { functionConfig.setParallelism(1); } if (functionConfig.getJar() != null) { functionConfig.setRuntime(FunctionConfig.Runtime.JAVA); } else if (functionConfig.getPy() != null) { functionConfig.setRuntime(FunctionConfig.Runtime.PYTHON); } WindowConfig windowConfig = functionConfig.getWindowConfig(); if (windowConfig != null) { WindowUtils.inferDefaultConfigs(windowConfig); functionConfig.setAutoAck(false); } }
functionConfig.setAutoAck(autoAck);