I am trying basic seda queue reader. I need to use java.util.concurrent.DelayQueue. *Q1.* Is it possible to read from this queue? Especially because this page <http://camel.apache.org/seda.html> says there are only three implementations of BlockingQueue are there: LinkedBlockingQueueFactory, ArrayBlockingQueueFactory and PriorityBlockingQueueFactory
DelayQueue objects need to implement Delayed interface. So I created DelayObject class implementing it: package com.mahesha999.examples.apachecamel.eg1; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; public class DelayObject implements Delayed { private String data; private long startTime; public DelayObject(String data, long delay) { this.data = data; this.startTime = System.currentTimeMillis() + delay; System.out.println(">>>>>>>>>>>>>>>>>> DelayObject created with params: " + data + "(" + delay + ")"); } public int compareTo(Delayed o) { if (this.startTime < ((DelayObject) o).startTime) { return -1; } if (this.startTime > ((DelayObject) o).startTime) { return 1; } return 0; } public long getDelay(TimeUnit unit) { long diff = startTime - System.currentTimeMillis(); return unit.convert(diff, TimeUnit.MILLISECONDS); } public String toString() { return "{" + "data='" + data + '\'' + ", startTime=" + startTime + '}'; } } Next I have written basic application context xml as below. It creates a DelayQueue loaded with single initial object. The camel route tries to read from the queue and output to the standard output stream. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"> <bean id="delayQueue" class="java.util.concurrent.DelayQueue"> <constructor-arg> <list> <bean id="delayedObject1" class="com.mahesha999.examples.apachecamel.eg1.DelayObject"> <constructor-arg type="java.lang.String"> <value>Mahesh</value> </constructor-arg> <constructor-arg type="long"> <value>10</value> </constructor-arg> </bean> </list> </constructor-arg> </bean> <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="seda:array?queue=#delayQueue" /> <to uri="stream:out" /> </route> </camelContext> </beans> Then my Main class looks like this: package com.mahesha999.examples.apachecamel.eg1; import java.util.concurrent.BlockingQueue; import org.apache.camel.CamelContext; import org.apache.camel.impl.DefaultCamelContext; import org.springframework.context.support.AbstractXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class App { public static void main(String[] args) throws InterruptedException { AbstractXmlApplicationContext springCtx = new ClassPathXmlApplicationContext("Eg1CamelContext.xml"); springCtx.start(); Thread.sleep(10000); springCtx.stop(); springCtx.destroy(); } } The DelayObject is getting created and seems that its getting added to the queue. But seda is not reading from it and outputing it to the standard output as the output looks like this: Jan 05, 2017 3:53:47 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@31221be2: startup date [Thu Jan 05 15:53:47 IST 2017]; root of context hierarchy Jan 05, 2017 3:53:47 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [Eg1CamelContext.xml] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Jan 05, 2017 3:53:48 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@22e357dc: defining beans [delayQueue,template,consumerTemplate,camel-1:beanPostProcessor,camel-1]; root of factory hierarchy >>>>>>>>>>>>>>>>>> DelayObject created with params: Mahesh(10) Jan 05, 2017 3:54:00 PM org.springframework.context.support.AbstractApplicationContext doClose INFO: Closing org.springframework.context.support.ClassPathXmlApplicationContext@31221be2: startup date [Thu Jan 05 15:53:47 IST 2017]; root of context hierarchy Jan 05, 2017 3:54:00 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@22e357dc: defining beans [delayQueue,template,consumerTemplate,camel-1:beanPostProcessor,camel-1]; root of factory hierarchy -- View this message in context: http://camel.465427.n5.nabble.com/How-to-read-from-queue-using-seda-tp5792183.html Sent from the Camel - Users mailing list archive at Nabble.com.