Hi

If you dont need a response, then set your MyListener sendMessage
method to be void.
Then Camel uses InOnly



On Sat, Apr 7, 2012 at 5:36 PM, Borut Bolčina <[email protected]> wrote:
> Hello,
>
> thanks for the time to look into it!
>
> So in Camel version 2.9.2 the above LongRunningBean will send out messages
> as expected? What about the @InOnly? When sending the messages out I do not
> need/expect a return/confirmation message. How will I achieve this?
>
> And, is there an ETA on 2.9.2? Thanks!
>
> -borut
>
> Dne 07. april 2012 11:44 je Claus Ibsen <[email protected]> napisal/-a:
>
>> Hi
>>
>> I reproduced the issue and logged a JIRA to improve this
>> https://issues.apache.org/jira/browse/CAMEL-5149
>>
>> On Sat, Apr 7, 2012 at 11:05 AM, Claus Ibsen <[email protected]>
>> wrote:
>> > Hi
>> >
>> > What version of Camel are you using?
>> >
>> > It looks like your bean does not get the @Produce injected from the
>> > route when you do
>> >  .bean(LongRunningBean.class, "startLongOperation")
>> >
>> >
>> >
>> > On Fri, Apr 6, 2012 at 3:04 PM, Borut Bolčina <[email protected]>
>> wrote:
>> >> Hello,
>> >>
>> >> I am trying to marry crawler4j with Camel and having some trouble
>> sending
>> >> messages out of my bean. The producer is not instantiated - I get NPE.
>> >>
>> >> My goal is to send each crawled page (html in string variable) to the
>> next
>> >> stage in the route. If I simplify the crawler with a demo bean:
>> >>
>> >> public class LongRunningBean {
>> >>    @Produce(uri = "direct:crawler")
>> >>    protected MyListener producer;
>> >>  List<String> outMessages = Arrays.asList("m1", "m2", "m3");
>> >>  public void startLongOperation() throws InterruptedException {
>> >>
>> >>  for (String message : outMessages) {
>> >>  String response = producer.sendMessage(message); // NPE
>> >>  Thread.sleep(2000);
>> >> }
>> >>  }
>> >> }
>> >>
>> >> and the
>> >>
>> >> public interface MyListener {
>> >> String sendMessage(String message);
>> >> }
>> >>
>> >> and my test route(s):
>> >>
>> >> public class LongRunningBeanTest extends CamelTestSupport {
>> >>
>> >> @Override
>> >>  protected RouteBuilder createRouteBuilder() throws Exception {
>> >>  return new RouteBuilder() {
>> >>  @Override
>> >> public void configure() throws Exception {
>> >> from("direct:start")
>> >>  .bean(LongRunningBean.class, "startLongOperation")
>> >> .to("log:bb.webcraft.crawler?level=DEBUG");
>> >>  from("direct:crawler")
>> >> .to("log:bb.webcraft.crawler?level=DEBUG");
>> >>  }
>> >> };
>> >> }
>> >>
>> >> @Test
>> >> public void testLongRun() throws Exception {
>> >> template.sendBody("direct:start", "myDummyMessage");
>> >>  assert(true);
>> >> }
>> >>  }
>> >>
>> >> I am getting NPE:
>> >>
>> >> [2012/04/06 14:23:26.478] ERROR [o.a.c.p.DefaultErrorHandler:log]:
>> Failed
>> >> delivery for (MessageId: ID-BOBB-50119-1333715006068-0-1 on ExchangeId:
>> >> ID-BOBB-50119-1333715006068-0-2). Exhausted after delivery attempt: 1
>> >> caught: java.lang.NullPointerException
>> >> java.lang.NullPointerException: null
>> >> at
>> >>
>> bb.webcraft.crawler.LongRunningBean.startLongOperation(LongRunningBean.java:19)
>> >> ~[test-classes/:na]
>> >>
>> >>
>> >> My goal is not to wait until the long running bean (crawler)
>> >> ends processing and then route an enormous number of objects in one
>> >> Exchange message, but send each crawled page's content to the next
>> stage in
>> >> the route as soon as it is processed.
>> >>
>> >> I saw only examples with activemq as producer's uri. Is this the trick?
>> >>
>> >> And one more thing - I don't need a return message as in:
>> >>
>> >> String response = producer.sendMessage(message);
>> >>
>> >> How to use the @InOnly or something else?
>> >>
>> >> Thanks,
>> >> Borut
>> >
>> >
>> >
>> > --
>> > Claus Ibsen
>> > -----------------
>> > CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
>> > FuseSource
>> > Email: [email protected]
>> > Web: http://fusesource.com
>> > Twitter: davsclaus, fusenews
>> > Blog: http://davsclaus.blogspot.com/
>> > Author of Camel in Action: http://www.manning.com/ibsen/
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
>> FuseSource
>> Email: [email protected]
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to