You used the asyncSend, which means it cannot block the sending thread. If you want producer is blocked, you need to use send API to send the message.
-- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (English) http://jnn.iteye.com (Chinese) Twitter: willemjiang Weibo: 姜宁willem On June 24, 2014 at 2:31:47 AM, swwyatt ([email protected]) wrote: > Hi, > > I'm am using a producer template to send to a seda endpoint and it's not > blocking when full. Is there something wrong with my configuration? Using > v2.12.1. > > > > > > > > > > > > > > uri="seda:workQueue?size=2&blockWhenFull=true&concurrentConsumers=2&timeout=0" > > > /> > > > > > > > > > > > > > > > public class FileProcessor implements Processor { > > private static final Logger logger = Logger.getLogger(FileProcessor.class); > > private Endpoint workQueueEndpoint; > private ProducerTemplate producerTemplate; > > @Override > public void process(Exchange exchange) throws Exception { > FileReader fileReader = new > FileReader(exchange.getIn().getBody(File.class)); > BufferedReader bufferedReader = new BufferedReader(fileReader); > Queue> futures = new LinkedList>(); > > for (String line = bufferedReader.readLine(); line != null; line = > bufferedReader.readLine()) { > logger.info("Sending " + line); > > futures.add(this.getProducerTemplate().asyncRequestBody(this.getWorkQueueEndpoint(), > > line)); > logger.info("Sent " + line); > } > > while (futures.size() > 0) { > Object o = futures.poll().get(); > logger.info("Result for " + o); > } > > bufferedReader.close(); > } > > public Endpoint getWorkQueueEndpoint() { > return workQueueEndpoint; > } > > public void setWorkQueueEndpoint(Endpoint workQueueEndpoint) { > this.workQueueEndpoint = workQueueEndpoint; > } > > public ProducerTemplate getProducerTemplate() { > return producerTemplate; > } > > public void setProducerTemplate(ProducerTemplate producerTemplate) { > this.producerTemplate = producerTemplate; > } > > } > > > public class DataProcessor implements Processor { > > private static final Logger logger = Logger.getLogger(DataProcessor.class); > > @Override > public void process(Exchange exchange) throws Exception { > Integer time = exchange.getIn().getBody(Integer.class); > > logger.info("Processing data " + time); > Thread.sleep(time.longValue()); > logger.info("Completed processing data " + time); > } > > } > > 2014-06-23 13:17:38,676|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sending 2000 > 2014-06-23 13:17:38,679|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sent 2000 > 2014-06-23 13:17:38,679|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sending 3000 > 2014-06-23 13:17:38,679|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sent 3000 > 2014-06-23 13:17:38,679|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sending 2500 > 2014-06-23 13:17:38,680|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sent 2500 > 2014-06-23 13:17:38,680|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sending 1000 > 2014-06-23 13:17:38,680|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sent 1000 > 2014-06-23 13:17:38,681|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sending 4000 > 2014-06-23 13:17:38,681|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sent 4000 > 2014-06-23 13:17:38,681|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sending 3500 > 2014-06-23 13:17:38,682|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sent 3500 > 2014-06-23 13:17:38,682|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sending 1500 > 2014-06-23 13:17:38,682|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Sent 1500 > 2014-06-23 13:17:38,691|Camel (test) thread #1 - seda://workQueue INFO > DataProcessor | process | Processing data 4000 > 2014-06-23 13:17:38,691|Camel (test) thread #2 - seda://workQueue INFO > DataProcessor | process | Processing data 2500 > 2014-06-23 13:17:41,192|Camel (test) thread #2 - seda://workQueue INFO > DataProcessor | process | Completed processing data 2500 > 2014-06-23 13:17:41,193|Camel (test) thread #2 - seda://workQueue INFO > DataProcessor | process | Processing data 3500 > 2014-06-23 13:17:42,692|Camel (test) thread #1 - seda://workQueue INFO > DataProcessor | process | Completed processing data 4000 > 2014-06-23 13:17:42,693|Camel (test) thread #1 - seda://workQueue INFO > DataProcessor | process | Processing data 1500 > 2014-06-23 13:17:44,193|Camel (test) thread #1 - seda://workQueue INFO > DataProcessor | process | Completed processing data 1500 > 2014-06-23 13:17:44,194|Camel (test) thread #1 - seda://workQueue INFO > DataProcessor | process | Processing data 2000 > 2014-06-23 13:17:44,693|Camel (test) thread #2 - seda://workQueue INFO > DataProcessor | process | Completed processing data 3500 > 2014-06-23 13:17:44,694|Camel (test) thread #2 - seda://workQueue INFO > DataProcessor | process | Processing data 3000 > 2014-06-23 13:17:46,195|Camel (test) thread #1 - seda://workQueue INFO > DataProcessor | process | Completed processing data 2000 > 2014-06-23 13:17:46,196|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Result for 2000 > 2014-06-23 13:17:46,196|Camel (test) thread #1 - seda://workQueue INFO > DataProcessor | process | Processing data 1000 > 2014-06-23 13:17:47,197|Camel (test) thread #1 - seda://workQueue INFO > DataProcessor | process | Completed processing data 1000 > 2014-06-23 13:17:47,695|Camel (test) thread #2 - seda://workQueue INFO > DataProcessor | process | Completed processing data 3000 > 2014-06-23 13:17:47,695|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Result for 3000 > 2014-06-23 13:17:47,696|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Result for 2500 > 2014-06-23 13:17:47,696|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Result for 1000 > 2014-06-23 13:17:47,696|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Result for 4000 > 2014-06-23 13:17:47,697|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Result for 3500 > 2014-06-23 13:17:47,697|Camel (test) thread #0 - file://c:/dvw/stream INFO > FileProcessor | process | Result for 1500 > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/seda-not-blocking-when-full-tp5752712.html > Sent from the Camel - Users mailing list archive at Nabble.com. >
