camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mick Knutson <mknut...@baselogic.com>
Subject Re: Virtual Topic routing with Camel
Date Thu, 06 Aug 2009 02:07:00 GMT
So I have this in my unit test now:

    @EndpointInject(uri = "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 = new RouteBuilder() {
            public void configure() {
                errorHandler(deadLetterChannel("mock:error"));


from("activemq:Player.1.VirtualTopic.TABLE.1").to("mock:player1");
            }
        };


        TableService tableService = (TableService) context
                .getBean("tableServiceProxy");
        boolean response = tableService.sendStatusUpdate("123");
        log.info("... the bet was successfully placed: " + response);
        assertTrue(response);

        String body = 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="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…

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 <willem.jiang@gmail.com> wrote:

> I think the consumer template should work.
> String body =
> 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 get
> 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 out
>> 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 need
>> right?
>>
>> ---
>> Thank You…
>>
>> 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 <willem.jiang@gmail.com>
>> 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 to
>>>> 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="activemq:**VirtualTopic.TABLE.1")
>>>>   ProducerTemplate producer;
>>>>
>>>>   public boolean sendStatusUpdate(String body) {
>>>>       log.info("//------------------**------------------------------**
>>>> ----------------//");
>>>>       log.info("sendStatusUpdate: " + body);
>>>>       log.info("//------------------**------------------------------**
>>>> ----------------//");
>>>>
>>>>       //Send message to
>>>>       producer.sendBody("<hello>**world!</hello>");
>>>>
>>>>       return true;
>>>>   }*
>>>>
>>>>
>>>> Here is my client unit test:
>>>>
>>>>   *@Test
>>>>   public void testGetStatusUpdateMessage() throws Exception {
>>>>       log.info("testGetStatusUpdateMessage");
>>>>
>>>>       TableService tableService = (TableService)
>>>> context.getBean("tableServiceProxy");
>>>>       boolean response = tableService.sendStatusUpdate("123");
>>>>       log.info("... the bet was successfully placed: " + response);
>>>>       assertTrue(response);
>>>>
>>>>       String body =
>>>> 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 waiting
>>>> for
>>>> a message to be delivered onto *activemq:Player.1.VirtualTopic.TABLE.1
>>>> *that
>>>> never arrives.
>>>>
>>>>
>>>> ---
>>>> Thank You…
>>>>
>>>> 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
>>>> ---
>>>>
>>>>
>>>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message