Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 41430 invoked from network); 6 Aug 2009 02:07:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Aug 2009 02:07:26 -0000 Received: (qmail 88082 invoked by uid 500); 6 Aug 2009 02:07:33 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 88018 invoked by uid 500); 6 Aug 2009 02:07:33 -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 88005 invoked by uid 99); 6 Aug 2009 02:07:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2009 02:07:33 +0000 X-ASF-Spam-Status: No, hits=3.4 required=10.0 tests=HTML_MESSAGE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.219.219] (HELO mail-ew0-f219.google.com) (209.85.219.219) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2009 02:07:22 +0000 Received: by ewy19 with SMTP id 19so585015ewy.20 for ; Wed, 05 Aug 2009 19:07:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.210.129.3 with SMTP id b3mr9042824ebd.34.1249524420431; Wed, 05 Aug 2009 19:07:00 -0700 (PDT) In-Reply-To: <4A7A3046.6030907@gmail.com> References: <56b1dfc30908051404w2550b5bbj909fa0e48925ce84@mail.gmail.com> <4A7A2BEE.3020209@gmail.com> <56b1dfc30908051808s4b4a0b11i7d474671abcf8039@mail.gmail.com> <4A7A3046.6030907@gmail.com> Date: Wed, 5 Aug 2009 19:07:00 -0700 Message-ID: <56b1dfc30908051907x48766cc6h698491a03cca0ffb@mail.gmail.com> Subject: Re: Virtual Topic routing with Camel From: Mick Knutson To: users@camel.apache.org Content-Type: multipart/alternative; boundary=0015174c3f4437d00a04706f934f X-Virus-Checked: Checked by ClamAV on apache.org --0015174c3f4437d00a04706f934f Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable So I have this in my unit test now: @EndpointInject(uri =3D "mock:player1") protected MockEndpoint mockPlayer; @Test public void testGetStatusUpdateMessage() throws Exception { log.info("testGetStatusUpdateMessage"); // we expect Hello World received in our mock endpoint mockPlayer.expectedBodiesReceived("Hello World"); RouteBuilder builder =3D new RouteBuilder() { public void configure() { errorHandler(deadLetterChannel("mock:error")); from("activemq:Player.1.VirtualTopic.TABLE.1").to("mock:player1"); } }; TableService tableService =3D (TableService) context .getBean("tableServiceProxy"); boolean response =3D tableService.sendStatusUpdate("123"); log.info("... the bet was successfully placed: " + response); assertTrue(response); String body =3D consumer.receiveBody( "activemq:Player.1.VirtualTopic.TABLE.1", String.class); assertEquals("Hello World", body); mock.assertIsSatisfied(); } Then on the server that I start up, I see: INFO: //----------------------------------------------------------------// Aug 5, 2009 7:04:01 PM com.wiredducks.service.impl.TableServiceImpl sendStatusUpdate INFO: sendStatusUpdate: 123 Aug 5, 2009 7:04:01 PM org.apache.activemq.transport.failover.FailoverTransport doReconnect INFO: Successfully connected to tcp://localhost:61616 Aug 5, 2009 7:04:02 PM com.wiredducks.service.impl.TableServiceImpl sendStatusUpdate INFO: //----- Messge Sent -----// Aug 5, 2009 7:04:02 PM com.wiredducks.service.impl.TableServiceImpl sendStatusUpdate INFO: //----------------------------------------------------------------// But I am not able to understand how to trace the message from the server to @EndpointInject(uri=3D"activemq:VirtualTopic.TABLE.1") to ensure it arrived there. Then on my client JUNit test case, it still hangs: *Running com.wiredducks.service.test.TableServiceTest 3955 [main] DEBUG org.apache.camel.impl.DefaultCamelContext - mock://player1 converted to endpoint: Endpoint[mock://player1] by component= : org.apache.camel.component.mock.MockComponent@c16f0c 3979 [main] INFO com.wiredducks.service.test.TableServiceTest - testGetStatusUpdateMessage 4084 [main] INFO com.wiredducks.service.test.TableServiceTest - ... the bet was successfully placed: true 4089 [main] DEBUG org.apache.camel.impl.DefaultCamelContext - activemq://Player.1.VirtualTopic.TABLE.1 converted to endpoint: Endpoint[activemq://Player.1.VirtualTopic.TABLE.1] by component: org.apache.activemq.camel.component.ActiveMQComponent@1dfd2293 4118 [ActiveMQ Task] INFO org.apache.activemq.transport.failover.FailoverTransport - Successfully connected to tcp://localhost:61616 * --- Thank You=85 Mick Knutson, President BASE Logic, Inc. Enterprise Architecture, Design, Mentoring & Agile Consulting p. (866) BLiNC-411: (254-6241-1) f. (415) 685-4233 Website: http://baselogic.com Linked IN: http://linkedin.com/in/mickknutson Vacation Rental: http://tahoe.baselogic.com --- On Wed, Aug 5, 2009 at 6:22 PM, Willem Jiang wrote= : > I think the consumer template should work. > String body =3D > consumer.receiveBody("activemq:Player.1.VirtualTopic.TABLE.1", > String.class); > > > Or you can try to setup the route rule first for the Unit test. > > form("activemq:Player.1.VirtualTopic.TABLE.1").to("mock:player1"); > > then you can using the camel mock API[1] to check if the mock endpoint ge= t > the message. > > [1]http://camel.apache.org/mock.html > > Willem > > > Mick Knutson wrote: > >> That is what I am trying to wrap my head around. I am trying to figure o= ut >> a >> way to either create a consumer like: >> http://camel.apache.org/activemq.html >> >> But still can't seem to understand how to fit this into a unit test in >> question. Not sure how that sets a remote destination which is what I ne= ed >> right? >> >> --- >> Thank You=85 >> >> Mick Knutson, President >> >> BASE Logic, Inc. >> Enterprise Architecture, Design, Mentoring & Agile Consulting >> p. (866) BLiNC-411: (254-6241-1) >> f. (415) 685-4233 >> >> Website: http://baselogic.com >> Linked IN: http://linkedin.com/in/mickknutson >> Vacation Rental: http://tahoe.baselogic.com >> --- >> >> >> >> On Wed, Aug 5, 2009 at 6:03 PM, Willem Jiang >> wrote: >> >> Can your consumer start to receive the message before calling the >>> sendStatusUpdate method ? >>> >>> You may need using other thread to call the sendStatusUpdate. >>> >>> Willem >>> >>> Mick Knutson wrote: >>> >>> Is there anything else I would have to setup with my embedded broker t= o >>>> be >>>> able to test sending a message to a VirtualTopic to get routed to the >>>> subscribed Queues? >>>> >>>> Here is what I have on my server: >>>> >>>> >>>> *@EndpointInject(uri=3D"activemq:**VirtualTopic.TABLE.1") >>>> ProducerTemplate producer; >>>> >>>> public boolean sendStatusUpdate(String body) { >>>> log.info("//------------------**------------------------------** >>>> ----------------//"); >>>> log.info("sendStatusUpdate: " + body); >>>> log.info("//------------------**------------------------------** >>>> ----------------//"); >>>> >>>> //Send message to >>>> producer.sendBody("**world!"); >>>> >>>> return true; >>>> }* >>>> >>>> >>>> Here is my client unit test: >>>> >>>> *@Test >>>> public void testGetStatusUpdateMessage() throws Exception { >>>> log.info("testGetStatusUpdateMessage"); >>>> >>>> TableService tableService =3D (TableService) >>>> context.getBean("tableServiceProxy"); >>>> boolean response =3D tableService.sendStatusUpdate("123"); >>>> log.info("... the bet was successfully placed: " + response); >>>> assertTrue(response); >>>> >>>> String body =3D >>>> consumer.receiveBody("activemq:Player.1.VirtualTopic.TABLE.1", >>>> String.class); >>>> >>>> assertEquals("Hello World", body); >>>> >>>> }* >>>> >>>> >>>> Now I am not able to get any body messages on >>>> *activemq:Player.1.VirtualTopic.TABLE.1 >>>> a*nd I have only used the embedded broker at this point. >>>> >>>> So what actually happens is my tests run freezes. I assume it is waiti= ng >>>> for >>>> a message to be delivered onto *activemq:Player.1.VirtualTopic.TABLE.1 >>>> *that >>>> never arrives. >>>> >>>> >>>> --- >>>> Thank You=85 >>>> >>>> Mick Knutson, President >>>> >>>> BASE Logic, Inc. >>>> Enterprise Architecture, Design, Mentoring & Agile Consulting >>>> p. (866) BLiNC-411: (254-6241-1) >>>> f. (415) 685-4233 >>>> >>>> Website: http://baselogic.com >>>> Linked IN: http://linkedin.com/in/mickknutson >>>> Vacation Rental: http://tahoe.baselogic.com >>>> --- >>>> >>>> >>>> >> > --0015174c3f4437d00a04706f934f--