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 BatchResequencerConfig extends ResequencerConfig {
033    @XmlAttribute
034    @Metadata(defaultValue = "100")
035    private Integer batchSize;
036    @XmlAttribute
037    @Metadata(defaultValue = "1000")
038    private Long batchTimeout;
039    @XmlAttribute
040    private Boolean allowDuplicates;
041    @XmlAttribute
042    private Boolean reverse;
043    @XmlAttribute
044    private Boolean ignoreInvalidExchanges;
045
046    /**
047     * Creates a new {@link BatchResequencerConfig} instance using default
048     * values for <code>batchSize</code> (100) and <code>batchTimeout</code>
049     * (1000L).
050     */
051    public BatchResequencerConfig() {
052        this(100, 1000L);
053    }
054
055    /**
056     * Creates a new {@link BatchResequencerConfig} instance using the given
057     * values for <code>batchSize</code> and <code>batchTimeout</code>.
058     *
059     * @param batchSize size of the batch to be re-ordered.
060     * @param batchTimeout timeout for collecting elements to be re-ordered.
061     */
062    public BatchResequencerConfig(int batchSize, long batchTimeout) {
063        this.batchSize = batchSize;
064        this.batchTimeout = batchTimeout;
065    }
066
067    /**
068     * Returns a new {@link BatchResequencerConfig} instance using default
069     * values for <code>batchSize</code> (100) and <code>batchTimeout</code>
070     * (1000L).
071     *
072     * @return a default {@link BatchResequencerConfig}.
073     */
074    public static BatchResequencerConfig getDefault() {
075        return new BatchResequencerConfig();
076    }
077
078    public int getBatchSize() {
079        return batchSize;
080    }
081
082    /**
083     * Sets the size of the batch to be re-ordered. The default size is 100.
084     */
085    public void setBatchSize(int batchSize) {
086        this.batchSize = batchSize;
087    }
088
089    public long getBatchTimeout() {
090        return batchTimeout;
091    }
092
093    /**
094     * Sets the timeout for collecting elements to be re-ordered. The default
095     * timeout is 1000 msec.
096     */
097    public void setBatchTimeout(long batchTimeout) {
098        this.batchTimeout = batchTimeout;
099    }
100
101    public Boolean getAllowDuplicates() {
102        return allowDuplicates;
103    }
104
105    /**
106     * Whether to allow duplicates.
107     */
108    public void setAllowDuplicates(Boolean allowDuplicates) {
109        this.allowDuplicates = allowDuplicates;
110    }
111
112    public Boolean getReverse() {
113        return reverse;
114    }
115
116    /**
117     * Whether to reverse the ordering.
118     */
119    public void setReverse(Boolean reverse) {
120        this.reverse = reverse;
121    }
122
123    public Boolean getIgnoreInvalidExchanges() {
124        return ignoreInvalidExchanges;
125    }
126
127    /**
128     * Whether to ignore invalid exchanges
129     */
130    public void setIgnoreInvalidExchanges(Boolean ignoreInvalidExchanges) {
131        this.ignoreInvalidExchanges = ignoreInvalidExchanges;
132    }
133}