297.3. 选择 BlockingQueue 实现
从 Camel 2.12 开始提供
默认情况下,SEDA 组件总是 intantiates LinkedBlockingQueue,但您可以使用不同的实现,您可以引用自己的 BlockingQueue 实现,在这种情况下,不使用 size 选项
<bean id="arrayQueue" class="java.util.ArrayBlockingQueue"> <constructor-arg index="0" value="10" ><!-- size --> <constructor-arg index="1" value="true" ><!-- fairness --> </bean> <!-- ... and later --> <from>seda:array?queue=#arrayQueue</from>
或者,您可以引用 BlockingQueueFactory 实现,3 个实现提供了 LinkedBlockingQueueFactory, ArrayBlockingQueueFactory 和 PriorityBlockingQueueFactory:
<bean id="priorityQueueFactory" class="org.apache.camel.component.seda.PriorityBlockingQueueFactory"> <property name="comparator"> <bean class="org.apache.camel.demo.MyExchangeComparator" /> </property> </bean> <!-- ... and later --> <from>seda:priority?queueFactory=#priorityQueueFactory&size=100</from>