You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by thelonesquirrely <th...@gmail.com> on 2011/09/30 23:18:39 UTC

Creating Postal Service using Camel

Hello - 

I need to make a postal service (point-to-point (direct) and publish (topic)
essentially). I was thinking that I could leverage most of the work that
camel has but I am a little confused.

Mainly I am having a problem dealing with the topic. I have an endpoint
defined as such: 

  <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="vm://localhost" />
  </bean>

and I have a route defined as such (in Java DSL) : 

  @Override
  public void configure () throws Exception {
    from ("activemq:topic:catcher").bean (Catcher.class);
  }

simple right? The catcher class just has on method: 

public class Catcher implements MessageListener {
  @Override
  public void onMessage (Message jmsMsg) {
    System.out.println (toString () + "-Recieved Message: " + jmsMsg);
  }
}

and something publishes a simple string to the topic: 
      // get the camel context using the CamelContextAware interface
      pTemplate.sendBody ("activemq:topic:catcher", new TestMessage (msg));

Then I have 3 catchers in the Spring context (Did i mention I was using
Spring?). None of these three are notified actually. It is a 4th that
presumably gets created that is notified. 

How would I arrange it so that the 3 get notified? Would I need to have them
each register their own route?  I want to try and encapsulate the routing
information in the PostalService - identify/describe/control the routes
there. I am open to suggestions! I am really just starting to look into this
and camel is...intimidating. Thanks!

--
View this message in context: http://camel.465427.n5.nabble.com/Creating-Postal-Service-using-Camel-tp4858438p4858438.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Creating Postal Service using Camel

Posted by Taariq Levack <ta...@gmail.com>.
Hi

Welcome to camel.

The reason your spring bean is not called is because you route to a class, like this; "bean (Catcher.class);"
That tells camel to create an instance of your class, have a look at beanRef, which allows you to refer to a bean already defined in spring.

Taariq

On 30 Sep 2011, at 11:18 PM, thelonesquirrely <th...@gmail.com> wrote:

> Hello - 
> 
> I need to make a postal service (point-to-point (direct) and publish (topic)
> essentially). I was thinking that I could leverage most of the work that
> camel has but I am a little confused.
> 
> Mainly I am having a problem dealing with the topic. I have an endpoint
> defined as such: 
> 
>  <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>    <property name="brokerURL" value="vm://localhost" />
>  </bean>
> 
> and I have a route defined as such (in Java DSL) : 
> 
>  @Override
>  public void configure () throws Exception {
>    from ("activemq:topic:catcher").bean (Catcher.class);
>  }
> 
> simple right? The catcher class just has on method: 
> 
> public class Catcher implements MessageListener {
>  @Override
>  public void onMessage (Message jmsMsg) {
>    System.out.println (toString () + "-Recieved Message: " + jmsMsg);
>  }
> }
> 
> and something publishes a simple string to the topic: 
>      // get the camel context using the CamelContextAware interface
>      pTemplate.sendBody ("activemq:topic:catcher", new TestMessage (msg));
> 
> Then I have 3 catchers in the Spring context (Did i mention I was using
> Spring?). None of these three are notified actually. It is a 4th that
> presumably gets created that is notified. 
> 
> How would I arrange it so that the 3 get notified? Would I need to have them
> each register their own route?  I want to try and encapsulate the routing
> information in the PostalService - identify/describe/control the routes
> there. I am open to suggestions! I am really just starting to look into this
> and camel is...intimidating. Thanks!
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Creating-Postal-Service-using-Camel-tp4858438p4858438.html
> Sent from the Camel - Users mailing list archive at Nabble.com.