You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Valerio VALDEZ Paolini <va...@staff.dada.net> on 2008/04/07 12:31:19 UTC

ActiveMQ and Camel

Hi,

I've been using ActiveMQ for some time and now I'm trying to figure out how
to leverage EIP via Camel. However, being completely new to Java and coming
from a Perl background, I'm experiencing some difficulties even running the
basic samples included along with the binary distribution of ActiveMQ-5.0.0.

Therefore I'm seeking your help to understand few basic things:

- is Camel shipped with ActiveMQ? Looking at sample configuration, it seems
  so, but Camel binary distribution includes a lot more files; should Camel
  be downloaded and started separately? Would you be so kind to share an
  example of how you setup it?

- if Camel inside ActiveMQ works out-of-the-box, why is example found at

	http://activemq.apache.org/camel/message-router.html

  throwing a Null Pointer exception during startup?

- is there a comprehensive documentation about configuring EIP rules using
  XML? Can you point me to some online reference?

See below for more details about versions used and configuration file.

Thanks in advance,

	Valerio

--

software:

ActiveMQ: 5.0.0 binary distribution

Java: tried both Java version 1.5.0_13 and 1.6.0_03 under Kubuntu

configuration:

<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.org/config/1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://activemq.org/config/1.0
      http://activemq.apache.org/schema/activemq-core.xsd
    http://activemq.apache.org/camel/schema/spring
      http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">

  <bean 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
  
  <broker xmlns="http://activemq.org/config/1.0" brokerName="localhost" 
dataDirectory="${activemq.base}/data">
    <destinations>
      <queue physicalName="dadanet.events.incoming" />
      <topic physicalName="dadanet.events.observer" />
      <queue physicalName="dadanet.events.dead" />
      <queue physicalName="dadanet.events.info" />
      <queue physicalName="dadanet.events.indexer" />
    </destinations>
  
    <destinationInterceptors>
      
      <virtualDestinationInterceptor>
        <virtualDestinations>
          <compositeQueue name="dadanet.events">
            <forwardTo>
              <queue physicalName="dadanet.events.incoming"/>
              <topic physicalName="dadanet.events.observer"/>
              <topic physicalName="dadanet.events.dead"/>
            </forwardTo>
          </compositeQueue>
        </virtualDestinations>
      </virtualDestinationInterceptor>

    </destinationInterceptors>

    <transportConnectors>
       <transportConnector name="stomp"   uri="stomp://localhost:61613"/>
    </transportConnectors>
  </broker>


  <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
  <route>
    <from uri="activemq:dadanet.events.incoming"/>
    <choice>
      <when>
        <predicate>
          <header name="X-event-type"/>
          <isEqualTo value="info"/>
        </predicate>
        <to uri="activemq:dadanet.events.info"/>
      </when>
      <when>
        <predicate>
          <header name="X-event-type"/>
          <isEqualTo value="indexer"/>
        </predicate>
        <to uri="activemq:dadanet.events.indexer"/>
      </when>
      <otherwise>
        <to uri="activemq:dadanet.events.dead"/>
      </otherwise>
    </choice>
  </route>
  </camelContext>
  
</beans>

Re: ActiveMQ and Camel

Posted by Valerio VALDEZ Paolini <va...@staff.dada.net>.
Hi James,

thanks for you prompt reply!

On Monday 07 April 2008 12:48:47 James Strachan wrote:
> >  - if Camel inside ActiveMQ works out-of-the-box, why is example found at
> >
> >         http://activemq.apache.org/camel/message-router.html
> >
> >   throwing a Null Pointer exception during startup?
>
> Could you show me the stack trace?

the log is below; let me know of any other piece of information you may need.

Thanks,

	Valerio

---------------------------

ACTIVEMQ_HOME: /opt/amq
ACTIVEMQ_BASE: /opt/amq
Loading message broker from: xbean:activemq.xml
INFO  BrokerService                  - ActiveMQ 5.0.0 JMS Message Broker 
(localhost) is starting
INFO  BrokerService                  - For help or more information please 
see: http://activemq.apache.org/
INFO  AMQPersistenceAdapter          - AMQStore starting using 
directory: /opt/amq/data/localhost
INFO  KahaStore                      - Kaha Store using data 
directory /opt/amq/data/localhost/kr-store/state
INFO  AMQPersistenceAdapter          - Active data files: []
WARN  AMQPersistenceAdapter          - The ReferenceStore is not valid - 
recovering ...
INFO  KahaStore                      - Kaha Store successfully deleted data 
directory /opt/amq/data/localhost/kr-store/data
INFO  KahaPersistenceAdapter         - Recovering subscriber state for durable 
subscriber: SubscriptionInfo {subscribedDestination = topic://ActiveMQ.Agent, 
destination = topic://ActiveMQ.Agent, clientId = 
NC_localhost_inboundlocalhost, subscriptionName = localhost_ActiveMQ.Agent, 
selector = null}
INFO  KahaStore                      - Kaha Store using data 
directory /opt/amq/data/localhost/kr-store/data
INFO  AMQPersistenceAdapter          - Journal Recovery Started from: 
DataManager:(data-)
INFO  AMQPersistenceAdapter          - Recovered 1 operations from redo log in 
0.177 seconds.
INFO  AMQPersistenceAdapter          - Finished recovering the ReferenceStore
INFO  BrokerService                  - Using Persistence Adapter: 
AMQPersistenceAdapter(/opt/amq/data/localhost)
INFO  ManagementContext              - JMX consoles can connect to 
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
INFO  TransportServerThreadSupport   - Listening for connections at: 
stomp://moto:61613
INFO  TransportConnector             - Connector stomp Started
INFO  BrokerService                  - ActiveMQ JMS Message Broker (localhost, 
ID:moto-37268-1207566407169-0:0) started
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: 
org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
java.lang.RuntimeException: Failed to execute start task. Reason: 
org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
	at 
org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:99)
	at 
org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:51)
	at 
org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:104)
	at 
org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:51)
	at 
org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:76)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.activemq.console.Main.runTaskClass(Main.java:222)
	at org.apache.activemq.console.Main.main(Main.java:106)
Caused by: org.apache.camel.RuntimeCamelException: 
java.lang.NullPointerException
	at 
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:98)
	at 
org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
	at 
org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
	at 
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
	at 
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
	at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
	at 
org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:64)
	at 
org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:52)
	at 
org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:91)
	at 
org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:51)
	at 
org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)
	at 
org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)
	at 
org.apache.activemq.console.command.StartCommand.startBroker(StartCommand.java:112)
	at 
org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:74)
	... 10 more
Caused by: java.lang.NullPointerException
	at 
org.apache.camel.model.ExpressionNode.createFilterProcessor(ExpressionNode.java:96)
	at org.apache.camel.model.WhenType.createProcessor(WhenType.java:49)
	at org.apache.camel.model.ChoiceType.createProcessor(ChoiceType.java:61)
	at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:882)
	at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:87)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:182)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:80)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:71)
	at 
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:449)
	at 
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:441)
	at 
org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:140)
	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:51)
	at 
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:96)
	... 23 more
ERROR: java.lang.Exception: org.apache.camel.RuntimeCamelException: 
java.lang.NullPointerException
java.lang.Exception: org.apache.camel.RuntimeCamelException: 
java.lang.NullPointerException
	at 
org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:100)
	at 
org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:51)
	at 
org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:104)
	at 
org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:51)
	at 
org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:76)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.activemq.console.Main.runTaskClass(Main.java:222)
	at org.apache.activemq.console.Main.main(Main.java:106)
Caused by: org.apache.camel.RuntimeCamelException: 
java.lang.NullPointerException
	at 
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:98)
	at 
org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77)
	at 
org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
	at 
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75)
	at 
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246)
	at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:355)
	at 
org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:64)
	at 
org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:52)
	at 
org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:91)
	at 
org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:51)
	at 
org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)
	at 
org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)
	at 
org.apache.activemq.console.command.StartCommand.startBroker(StartCommand.java:112)
	at 
org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:74)
	... 10 more
Caused by: java.lang.NullPointerException
	at 
org.apache.camel.model.ExpressionNode.createFilterProcessor(ExpressionNode.java:96)
	at org.apache.camel.model.WhenType.createProcessor(WhenType.java:49)
	at org.apache.camel.model.ChoiceType.createProcessor(ChoiceType.java:61)
	at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:882)
	at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:87)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:182)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:80)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:71)
	at 
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:449)
	at 
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:441)
	at 
org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:140)
	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:51)
	at 
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:96)
	... 23 more


-----------------------------

-- 

Valerio Paolini - valerio.paolini@staff.dada.net
The lyf so short, the craft so long to lerne - Geoffrey Chaucer

Re: ActiveMQ and Camel

Posted by James Strachan <ja...@gmail.com>.
On 07/04/2008, Valerio VALDEZ Paolini <va...@staff.dada.net> wrote:
> Hi,
>
>  I've been using ActiveMQ for some time and now I'm trying to figure out how
>  to leverage EIP via Camel. However, being completely new to Java and coming
>  from a Perl background, I'm experiencing some difficulties even running the
>  basic samples included along with the binary distribution of ActiveMQ-5.0.0.
>
>  Therefore I'm seeking your help to understand few basic things:
>
>  - is Camel shipped with ActiveMQ? Looking at sample configuration, it seems
>   so, but Camel binary distribution includes a lot more files; should Camel
>   be downloaded and started separately? Would you be so kind to share an
>   example of how you setup it?

There should be enough of Camel inside the ActiveMQ broker to do most
of what you need; but you might wanna add a few more jars depending on
how complex your camel routes are.

e.g. the out of the box ActiveMQ comes with core Camel support
(camel-core) within support for files, SEDA, XSLT and mock testing
endpoints - along with spring support (camel-spring) and JMS support.

However if you wanted support for other components; such as mail,
you'd need to add more jars (e.g. camel-mail and its dependencies such
as JavaMail etc)


>  - if Camel inside ActiveMQ works out-of-the-box, why is example found at
>
>         http://activemq.apache.org/camel/message-router.html
>
>   throwing a Null Pointer exception during startup?

Could you show me the stack trace?


>  - is there a comprehensive documentation about configuring EIP rules using
>   XML? Can you point me to some online reference?
>
>  See below for more details about versions used and configuration file.

Here's all the docs we've got so far...
http://activemq.apache.org/camel/user-guide.html

in particular
http://activemq.apache.org/camel/xml-configuration.html

which includes a link to the online reference for the XSDs etc

Hopefully the documentation will improve soon.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com