001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.model.config;
018
019import javax.xml.bind.annotation.XmlAccessType;
020import javax.xml.bind.annotation.XmlAccessorType;
021import javax.xml.bind.annotation.XmlAttribute;
022import javax.xml.bind.annotation.XmlRootElement;
023
024import org.apache.camel.spi.Metadata;
025
026/**
027 * Configures batch-processing resequence eip.
028 */
029@Metadata(label = "eip,routing,resequence")
030@XmlRootElement(name = "batch-config")
031@XmlAccessorType(XmlAccessType.FIELD)
032public class
033BatchResequencerConfig extends ResequencerConfig {
034    @XmlAttribute
035    @Metadata(defaultValue = "100", javaType = "java.lang.Integer")
036    private String batchSize;
037    @XmlAttribute
038    @Metadata(defaultValue = "1s", javaType = "java.time.Duration")
039    private String batchTimeout;
040    @XmlAttribute
041    @Metadata(javaType = "java.lang.Boolean")
042    private String allowDuplicates;
043    @XmlAttribute
044    @Metadata(javaType = "java.lang.Boolean")
045    private String reverse;
046    @XmlAttribute
047    @Metadata(javaType = "java.lang.Boolean")
048    private String ignoreInvalidExchanges;
049
050    /**
051     * Creates a new {@link BatchResequencerConfig} instance using default
052     * values for <code>batchSize</code> (100) and <code>batchTimeout</code>
053     * (1000L).
054     */
055    public BatchResequencerConfig() {
056        this(100, 1000L);
057    }
058
059    /**
060     * Creates a new {@link BatchResequencerConfig} instance using the given
061     * values for <code>batchSize</code> and <code>batchTimeout</code>.
062     *
063     * @param batchSize size of the batch to be re-ordered.
064     * @param batchTimeout timeout for collecting elements to be re-ordered.
065     */
066    public BatchResequencerConfig(int batchSize, long batchTimeout) {
067        this.batchSize = Integer.toString(batchSize);
068        this.batchTimeout = Long.toString(batchTimeout);
069    }
070
071    /**
072     * Returns a new {@link BatchResequencerConfig} instance using default
073     * values for <code>batchSize</code> (100) and <code>batchTimeout</code>
074     * (1000L).
075     *
076     * @return a default {@link BatchResequencerConfig}.
077     */
078    public static BatchResequencerConfig getDefault() {
079        return new BatchResequencerConfig();
080    }
081
082    public String getBatchSize() {
083        return batchSize;
084    }
085
086    /**
087     * Sets the size of the batch to be re-ordered. The default size is 100.
088     */
089    public void setBatchSize(String batchSize) {
090        this.batchSize = batchSize;
091    }
092
093    public String getBatchTimeout() {
094        return batchTimeout;
095    }
096
097    /**
098     * Sets the timeout for collecting elements to be re-ordered. The default
099     * timeout is 1000 msec.
100     */
101    public void setBatchTimeout(String batchTimeout) {
102        this.batchTimeout = batchTimeout;
103    }
104
105    public String getAllowDuplicates() {
106        return allowDuplicates;
107    }
108
109    /**
110     * Whether to allow duplicates.
111     */
112    public void setAllowDuplicates(String allowDuplicates) {
113        this.allowDuplicates = allowDuplicates;
114    }
115
116    public String getReverse() {
117        return reverse;
118    }
119
120    /**
121     * Whether to reverse the ordering.
122     */
123    public void setReverse(String reverse) {
124        this.reverse = reverse;
125    }
126
127    public String getIgnoreInvalidExchanges() {
128        return ignoreInvalidExchanges;
129    }
130
131    /**
132     * Whether to ignore invalid exchanges
133     */
134    public void setIgnoreInvalidExchanges(String ignoreInvalidExchanges) {
135        this.ignoreInvalidExchanges = ignoreInvalidExchanges;
136    }
137}