views:

557

answers:

2

I am trying to get a simple demo started with ActiveMQ that will demonstrate a TCP to TCP route. I am coding the endpoints and routes in a camel context in my activemq.xml configuration file.

<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt;

    <package>org.myorg.codec</package>

    <endpoint id="listener_A" uri="mina:tcp://localhost:42000?sync=false&amp;textline=true"/>
 <endpoint id="listener_B" uri="mina:tcp://localhost:42001?sync=false&amp;textline=true"/>

    <route>
        <from uri="activemq:listener_A"/>
        <to uri="activemq:listener_B"/>
    </route>
    <route>
        <from uri="activemq:listener_B"/>
        <to uri="activemq:listener_A"/>
    </route>
</camelContext>

Any idea why this doesn't work?

The AMQ server does not seem to be opening a listening port.

Edit: The intent here, as a simple demonstation, is to connect to ActiveMQ with two telnet terminals (A and B) and be able to route messages from one to another through the message queue server. Later, I may try filtering or routing based on content.

+1  A: 

I'm a bit confused by your configuration file. What exactly are you trying to do?

You've defined 2 endpoints for using MINA (which won't use ActiveMQ at all); then you are using a route from an ActievMQ queue listener_A to listener_B then listener_B to listener_A (which is a recursive loop).

Maybe if you start describing what you want to do we can figure out what the XML should look like.

Incidentally if you just want to refer to endpoints you've defined, use the ref="name" attribute rather than uri="...".

e.g.

<route>
  <from ref="listener_A"/>
  <to ref="listener_B"/>
</route>

All that being said - you tend to get better & faster support on Camel via the Camel User Forum

James Strachan
@James, thanks, your point about the loop is blindingly obvious.
JeffV
but do you want an infinite loop - where sending 1 message is gonna pretty much take down MINA/ActiveMQ processing the same single message going round and around?Loops in message queues / async programs are normally really bad
James Strachan
A: 

More on this:

When the endpoint is defined as a mina tcp connection, it cannot be identified as "activemq::listener_A"

<endpoint id="listener_A" uri="mina:tcp://localhost:42000?sync=false&amp;textline=true"/>

this is wrong:

  <from uri="activemq:listener_A"/>

this works:

  <from ref="listener_A"/>

so does this:

  <from ref="mina:tcp://localhost:42000?sync=false&amp;textline=true"/>
JeffV