This looks like a good case for using a polling consumer, more info
here - http://camel.apache.org/polling-consumer.html

I've knocked together a quick unit test to be sure it's going to work
for you, here's an example:

//---------------------------------------------------------------------------
package org.apache.camel.component.mina;

import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.PollingConsumer;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;

/**
 * @version $Revision: 722878 $
 */
public class MinaPollingConsumerTest extends ContextTestSupport {
    protected String consumerUri =
"mina:tcp://localhost:8080?sync=false&minaLogger=true";
    protected String targetUri =
"mina:tcp://localhost:8081?sync=false&minaLogger=true";

    public void testMinaRoute() throws Exception {
        MockEndpoint endpoint = getMockEndpoint("mock:result");
        Object body = "Hello there!";
        endpoint.expectedBodiesReceived(body);

        // just to get the consumer running so our route can connect...
        consumer.receive(targetUri, 1000);

        template.sendBody(consumerUri, body);

        // receive the message sent by the producer template
        Exchange exchange = consumer.receive(targetUri, 1000);

        template.sendBody("direct:foo", exchange.getIn().getBody());

        assertMockEndpointsSatisfied();
    }

    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
                from(consumerUri).to(targetUri);
                from("direct:foo").to("mock:result");

            }
        };
    }
}
//---------------------------------------------------------------------------

Hope that helps!

On Tue, Feb 2, 2010 at 3:02 PM, Dean H <[email protected]> wrote:
>
> Hello, I'm new to Camel.  I'm having some trouble getting my application
> working correctly.  I've read through the http://camel.apache.org/mina.html
> page several times but I'm not having much luck.
>
> here is my scenario:
> There is a tcp server that I need to connect to on a specified port.  The
> server will periodically send xml strings that I will receive.  I'd like my
> camel component to block indefinitely waiting to receive a message from the
> server.  When a message is received, i'd like to automatically deserialize
> it into an object that I can then pass into my bean.
>
> I am attempting to configure my route in spring with something like this:
>
> <route>
>  <from uri="mina:tcp://serverIP:port"/>
>  <unmarshal ref="jaxb">
>  <bean ref="myBean" method="invoke"/>
> </route>
>
> It seems that the "from" is continually attempting to function as the server
> rather than the client.  Thus, it attempts to bind to the server ip/port
> (which is already allocated to the actual server process) and fails.  Can
> someone provide an example configuration that accomplishes what I'm looking
> to do?
>
> --
> View this message in context: 
> http://old.nabble.com/MINA-questions-tp27426504p27426504.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Reply via email to