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