orpiske commented on a change in pull request #6947: URL: https://github.com/apache/camel/pull/6947#discussion_r816568715
########## File path: core/camel-core-processor/src/main/java/org/apache/camel/processor/resume/ResumableCompletion.java ########## @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.camel.processor.resume; + +import org.apache.camel.Exchange; +import org.apache.camel.Resumable; +import org.apache.camel.ResumeStrategy; +import org.apache.camel.UpdatableConsumerResumeStrategy; +import org.apache.camel.spi.Synchronization; +import org.apache.camel.support.ExchangeHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ResumableCompletion implements Synchronization { + private static final Logger LOG = LoggerFactory.getLogger(ResumableCompletion.class); + + private final ResumeStrategy resumeStrategy; + private final Resumable<?, ?> resumable; + + public ResumableCompletion(ResumeStrategy resumeStrategy, Resumable<?, ?> resumable) { + this.resumeStrategy = resumeStrategy; + this.resumable = resumable; + } + + @Override + public void onComplete(Exchange exchange) { + if (!ExchangeHelper.isFailureHandled(exchange)) { + if (resumeStrategy instanceof UpdatableConsumerResumeStrategy) { + UpdatableConsumerResumeStrategy updatableConsumerResumeStrategy + = (UpdatableConsumerResumeStrategy) resumeStrategy; + try { + updatableConsumerResumeStrategy.updateLastOffset(resumable); + } catch (Exception e) { + LOG.error("Unable to update the offset: {}", e.getMessage(), e); + } + } else { + LOG.warn("Cannot perform an offset update because the strategy is not updatable"); + } + } + } + + @Override + public void onFailure(Exchange exchange) { + LOG.warn("Skipping offset update for {} due to failure in processing", resumable.getAddressable()); Review comment: I think that's a good point. What I am concerned here is how we can possibly notify the user that the update process has not gone forward. I'd like to avoid failing silently, but flooding the logs is not good either. Do you have any suggestion? -- 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: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org