Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6A3E5911E for ; Sat, 7 Apr 2012 09:45:12 +0000 (UTC) Received: (qmail 96271 invoked by uid 500); 7 Apr 2012 09:45:11 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 96205 invoked by uid 500); 7 Apr 2012 09:45:11 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 96192 invoked by uid 99); 7 Apr 2012 09:45:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Apr 2012 09:45:11 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.215.45 as permitted sender) Received: from [209.85.215.45] (HELO mail-lpp01m010-f45.google.com) (209.85.215.45) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Apr 2012 09:45:05 +0000 Received: by lahe6 with SMTP id e6so3342974lah.32 for ; Sat, 07 Apr 2012 02:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=ls9At/OlSbSvt8ZP7F787q/+HFnBkjngC6dZOpwopqw=; b=ceHBD7zA2xntCUh+S+7rIkl8ANhMDFd8b/BXtFDDLmJ25RQd2CES24kEHtIVymeAcQ TKt4srGqoCawB+zoRhZnfnzCnI5rjyI2dppA2tcyheIQMWKBe7IUMvKU4D2JcPcj+gco LvvKBrZ60zb9mAvQqoqDprzJQE5uYL9C0NaHRm51oQSPQU8yntBN7ZO4mZxlsMRk0BbR OsxNkmkUSy1EQeg7mGAP1SzdWNJPcwX8lEsn7zTl0y1WWUyC/bSP6goYCW5nuvCZ4phL yySDPIfW3HR826HhIskRcfuwQ43rFzp3/gqWraL/stJga6pwW3uwYUYE14gRIiEbwgnp Myyg== Received: by 10.152.132.166 with SMTP id ov6mr1474369lab.35.1333791884475; Sat, 07 Apr 2012 02:44:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.75.130 with HTTP; Sat, 7 Apr 2012 02:44:24 -0700 (PDT) In-Reply-To: References: From: Claus Ibsen Date: Sat, 7 Apr 2012 11:44:24 +0200 Message-ID: Subject: Re: My long running bean sending out messages To: users@camel.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 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 > =C2=A0.bean(LongRunningBean.class, "startLongOperation") > > > > On Fri, Apr 6, 2012 at 3:04 PM, Borut Bol=C4=8Dina wrote: >> Hello, >> >> I am trying to marry crawler4j with Camel and having some trouble sendin= g >> 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 ne= xt >> stage in the route. If I simplify the crawler with a demo bean: >> >> public class LongRunningBean { >> =C2=A0 =C2=A0@Produce(uri =3D "direct:crawler") >> =C2=A0 =C2=A0protected MyListener producer; >> =C2=A0List outMessages =3D Arrays.asList("m1", "m2", "m3"); >> =C2=A0public void startLongOperation() throws InterruptedException { >> >> =C2=A0for (String message : outMessages) { >> =C2=A0String response =3D producer.sendMessage(message); // NPE >> =C2=A0Thread.sleep(2000); >> } >> =C2=A0} >> } >> >> and the >> >> public interface MyListener { >> String sendMessage(String message); >> } >> >> and my test route(s): >> >> public class LongRunningBeanTest extends CamelTestSupport { >> >> @Override >> =C2=A0protected RouteBuilder createRouteBuilder() throws Exception { >> =C2=A0return new RouteBuilder() { >> =C2=A0@Override >> public void configure() throws Exception { >> from("direct:start") >> =C2=A0.bean(LongRunningBean.class, "startLongOperation") >> .to("log:bb.webcraft.crawler?level=3DDEBUG"); >> =C2=A0from("direct:crawler") >> .to("log:bb.webcraft.crawler?level=3DDEBUG"); >> =C2=A0} >> }; >> } >> >> @Test >> public void testLongRun() throws Exception { >> template.sendBody("direct:start", "myDummyMessage"); >> =C2=A0assert(true); >> } >> =C2=A0} >> >> I am getting NPE: >> >> [2012/04/06 14:23:26.478] ERROR [o.a.c.p.DefaultErrorHandler:log]: Faile= d >> 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.j= ava: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 =3D 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: cibsen@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/ --=20 Claus Ibsen ----------------- CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com FuseSource Email: cibsen@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/