Apache-camel Seda端点,BlockWhenFull未得到承认

时间:2016-01-22 14:59:55

标签: apache-camel

from("seda:myqueue?size=2&blockWhenFull=true").process(sleep());



private Processor sleep() {
                return new Processor() {                    
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        String body = exchange.getIn().getBody(String.class);
                        System.out.println(curTime() + " Going for sleep sleepid=" + body );
                        Thread.sleep(5000l);                        
                        System.out.println(curTime() + " Done sleep sleepid=" + body );
                    }
                };



for (Integer i = 0; i <5; i++) {            
            Exchange exchange = new DefaultExchange(context);
            exchange.setPattern(ExchangePattern.InOnly);
            exchange.getIn().setHeader("header", i);
            exchange.getIn().setBody(i.toString());
           System.out.println("sending msg to seda");
           Exchange send = template.send("seda:myqueue",exchange);
           System.out.println("done:"+i);

        }

&#34; BlockWhenFull&#34;没有确认,即如果大小设置为2并且我在一个循环中发送3 msg,并且身体为&#34; 1&#34; ,&#34; 2&#34;和&#34; 3&#34;比我睡觉时只为#34; 1&#34;和&#34; 2&#34;我猜第三个msg即使在我设置了&#34; BlockWhenFull&#34;是的。

我做错了什么?

版本:2.15.3

1 个答案:

答案 0 :(得分:3)

您需要在制作人处设置blockWhenFull,例如您发送的地方

template.send("seda:myqueue?blockWhenFull=true",exchange);