You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by triggershot <da...@gmx.de> on 2009/06/12 13:37:20 UTC

How do i use a JMS Consumer in Camel DSL?

Hey,

i have the following problem. I've defined a JMS - Service Unit with a
Provider and Consumer (like in the Tutorial "Camel" from
servicemix.apache.org):

######################################################
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
       xmlns:tutorial="urn:org:apache:servicemix:tutorial:camel"
       xmlns:amq="http://activemq.org/config/1.0">
    <jms:provider service="tutorial:jms"
                  endpoint="provider" 
                  destinationName="tutorial.camel.queue"
                  connectionFactory="#connectionFactory" />
    <jms:consumer service="tutorial:jms"
	          endpoint="consumer"
	          destinationName="tutorial.camel.queue"
	          connectionFactory="#connectionFactory"
	          targetService="tutorial:jms"
	          targetEndpoint="consumer" />	
     <amq:connectionFactory id="connectionFactory"
brokerURL="tcp://localhost:61616" />
</beans>
######################################################


And here is my Camel MyRouteBuilder.java:

######################################################
public class MyRouteBuilder extends RouteBuilder 
{
public void configure() 
{
  from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
  .setBody(constant("<message>This is a  test</message>"))
  .convertBodyTo(DOMSource.class)
  .to("jbi:endpoint:urn:org:apache:servicemix:tutorial:camel:jms:provider");
	    	
  from("jbi:endpoint:urn:org:apache:servicemix:tutorial:camel:jms:consumer")
  .to("log:mylogger");
}
}
######################################################


The message receives the provider. But my Consumer cannot "get" the message
from the Queue. I get the following error:

######################################################
13:35:09,500 | WARN  | nerContainer-498 | DefaultMessageListenerContainer  |
AbstractMessageListenerContainer  646 | Execution of JMS message listener
failed
javax.jms.JMSException: Error sending JBI exchange
        at
org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:575)
        at
org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint$1.onMessage(JmsConsumerEndpoint.java:505)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:518)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:479)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
        at
java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:881)
        at
org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.pending(AssemblyReferencesListener.java:110)
        at
org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.exchangeSent(AssemblyReferencesListener.java:98)
        at
org.apache.servicemix.nmr.core.ChannelImpl.dispatch(ChannelImpl.java:282)
        at
org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:141)
        at
org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:127)
        at
org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:187)
        at
org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:115)
        at
org.apache.servicemix.common.endpoints.SimpleEndpoint.sendSync(SimpleEndpoint.java:74)
        at
org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:548)
######################################################

What ' s the reason? I only want this:
- write a Message to the JMS provider
- JMS consumer polls the ActiveMQueue and if a message is incoming it writes
the message-content back to the ServiceMix-Log.

Where is the error?
-- 
View this message in context: http://www.nabble.com/How-do-i-use-a-JMS-Consumer-in-Camel-DSL--tp23997268p23997268.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i use a JMS Consumer in Camel DSL?

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

My comment inline
On 2011-11-24, at 下午11:05, Ashish wrote:

> Hi,
> I am new to servicemix. trying to write a simple example in which a  
> file
> contents are copied from a directory to a jms queue which in turn  
> transfers
> it to another directory. The xml file is as follows:-
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xmlns:osgi="http://www.springframework.org/schema/osgi"
>   xmlns:file="http://servicemix.apache.org/file/1.0"
>   xmlns:jms="http://servicemix.apache.org/jms/1.0"
>   xmlns:ifm="http://www.fico.com"
>   xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
>       http://www.springframework.org/schema/osgi
> http://www.springframework.org/schema/osgi/spring-osgi.xsd
>       http://servicemix.apache.org/file/1.0
> http://servicemix.apache.org/file/1.0/servicemix-file.xsd
>       http://servicemix.apache.org/jms/1.0
> http://servicemix.apache.org/jms/1.0/servicemix-file.xsd">
>
At least this is incorrect
it should be
http://servicemix.apache.org/jms/1.0/servicemix-jms.xsd
but not
http://servicemix.apache.org/jms/1.0/servicemix-file.xsd


Btw, you should post this question to Servicemix user mailling list,  
as this is a Servicemix specific question.

Freeman
>
>    <bean class="org.apache.servicemix.common.osgi.EndpointExporter" />
>
>
>    <bean id="propertyConfigurer"
> class 
> = 
> "org 
> .springframework.beans.factory.config.PropertyPlaceholderConfigurer"
> />
>
>    <manifest>
>       Bundle-Version = 1.0.0
>       Bundle-Name = Data Handler Service Application
>       Bundle-SymbolicName = org.apache.servicemix.examples.filemover
>       Bundle-Description = An example which reads a file from an input
> folder and writes it to an output folder
>       Bundle-Vendor = lhein@apache.org
>       Require-Bundle = servicemix-file
>    </manifest>
>
>
>  <file:poller service="ifm:file"
>               endpoint="poller"
>               autoCreateDirectory="true"
>               file="C:/dh-in"
>               targetService="ifm:JmsTarget"
>               period="8000"
>               delay="4000"
>               deleteFile="true"
>               recursive="true">
>
>     <property name="marshaler">
>        <bean
> class 
> ="org.apache.servicemix.components.util.SimpleFlatFileMarshaler" />
>     </property>
>
>  </file:poller>
>
>
>  <file:sender service="ifm:file"
>               endpoint="sender"
>               append="false"
>               autoCreateDirectory="true"
>               directory="C:/dh-out">
>
>    <property name="marshaler">
>        <bean
> class 
> ="org.apache.servicemix.components.util.SimpleFlatFileMarshaler" />
>     </property>
>
>  </file:sender>
>
>      <jms:consumer service="ifm:JmsSource" endpoint="jms"
>                    targetService="ifm:file" targetEndpoint="sender"
>                    destinationName="queue/FileJmsMover"
> connectionFactory="#connectionFactory" />
>
>      <jms:provider service="ifm:JmsTarget" endpoint="jms"
>                    destinationName="queue/FileJmsMover"
> connectionFactory="#connectionFactory" />
>
>
>  	<bean id="connectionFactory"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>  		<property name="jndiName" value="java:/XAQueueConnectionFactory"/>
>                  <property name="lookupOnStartup" value="true"/>
> 	</bean>	
>
> </beans>
>
> ***********
>
> While deploying this I am getting this error in log - "The matching  
> wildcard
> is strict, but no declaration can be found for element  
> 'jms:consumer'". any
> help on how to solve this will be highly appreciated.
>
> Thanks in advance,
> aashish
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-do-i-use-a-JMS-Consumer-in-Camel-DSL-tp475447p5020399.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

---------------------------------------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com










Re: How do i use a JMS Consumer in Camel DSL?

Posted by Ashish <as...@gmail.com>.
Hi,
I am new to servicemix. trying to write a simple example in which a file
contents are copied from a directory to a jms queue which in turn transfers
it to another directory. The xml file is as follows:-

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"                              
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:osgi="http://www.springframework.org/schema/osgi"           
   xmlns:file="http://servicemix.apache.org/file/1.0"
   xmlns:jms="http://servicemix.apache.org/jms/1.0"
   xmlns:ifm="http://www.fico.com"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd                     
       http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
       http://servicemix.apache.org/file/1.0
http://servicemix.apache.org/file/1.0/servicemix-file.xsd
       http://servicemix.apache.org/jms/1.0
http://servicemix.apache.org/jms/1.0/servicemix-file.xsd">

    
    <bean class="org.apache.servicemix.common.osgi.EndpointExporter" />

    
    <bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
/>

    <manifest>
       Bundle-Version = 1.0.0
       Bundle-Name = Data Handler Service Application
       Bundle-SymbolicName = org.apache.servicemix.examples.filemover
       Bundle-Description = An example which reads a file from an input
folder and writes it to an output folder
       Bundle-Vendor = lhein@apache.org
       Require-Bundle = servicemix-file
    </manifest>

  
  <file:poller service="ifm:file"
               endpoint="poller"
               autoCreateDirectory="true"
               file="C:/dh-in"
               targetService="ifm:JmsTarget"
               period="8000"
               delay="4000"
               deleteFile="true"
               recursive="true">

     <property name="marshaler">
        <bean
class="org.apache.servicemix.components.util.SimpleFlatFileMarshaler" />
     </property>

  </file:poller>

  
  <file:sender service="ifm:file"
               endpoint="sender"
               append="false"
               autoCreateDirectory="true"
               directory="C:/dh-out">

    <property name="marshaler">
        <bean
class="org.apache.servicemix.components.util.SimpleFlatFileMarshaler" />
     </property>
    
  </file:sender>
  
      <jms:consumer service="ifm:JmsSource" endpoint="jms"
                    targetService="ifm:file" targetEndpoint="sender"
                    destinationName="queue/FileJmsMover"
connectionFactory="#connectionFactory" />
  
      <jms:provider service="ifm:JmsTarget" endpoint="jms"
                    destinationName="queue/FileJmsMover"
connectionFactory="#connectionFactory" />
  
      
  	<bean id="connectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
  		<property name="jndiName" value="java:/XAQueueConnectionFactory"/>
                  <property name="lookupOnStartup" value="true"/>
	</bean>	
  
</beans>

***********

While deploying this I am getting this error in log - "The matching wildcard
is strict, but no declaration can be found for element 'jms:consumer'". any
help on how to solve this will be highly appreciated.

Thanks in advance,
aashish

--
View this message in context: http://camel.465427.n5.nabble.com/How-do-i-use-a-JMS-Consumer-in-Camel-DSL-tp475447p5020399.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How do i use a JMS Consumer in Camel DSL?

Posted by Willem Jiang <wi...@gmail.com>.
Yes. You just need to update the serviemix-camel component.

Another work around method is using the serviceMix3 serivce unit instead
of ServiceMix4's osgi bundle to deploy your camel context.
But you may need to build up the camel-servicemix service-engine youself
to add the camel-jms component into the it.
Here is a FAQ[1] which discuss about it.
[1]
http://cwiki.apache.org/CAMEL/how-to-use-extra-camel-componets-in-servicemix-camel.html

Willem
triggershot wrote:
> Is it sufficient to update the servicemix-camel to use a JMS consumer in
> camel contexts?


Re: How do i use a JMS Consumer in Camel DSL?

Posted by triggershot <da...@gmx.de>.
Is it sufficient to update the servicemix-camel to use a JMS consumer in
camel contexts?
-- 
View this message in context: http://www.nabble.com/How-do-i-use-a-JMS-Consumer-in-Camel-DSL--tp23997268p24048768.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i use a JMS Consumer in Camel DSL?

Posted by Willem Jiang <wi...@gmail.com>.
Try latest snapshot of Servicemix, or apply the patch yourself :)

triggershot wrote:
> Does anybody have a good Work-around? 
> 
> 
> willem.jiang wrote:
>> Hi
>>
>> It's a known issue[1], and we fixed it in SMX4 branch.
>> If you are not comfortable with playing apache SNAPSHOT version, you can
>> try out the coming up Fuse ESB 4.1.x monthly release version.
>>
>> [1] http://fusesource.com/issues/browse/ESB-733
>>
>> Willem
>>


Re: How do i use a JMS Consumer in Camel DSL?

Posted by triggershot <da...@gmx.de>.
Does anybody have a good Work-around? 


willem.jiang wrote:
> 
> Hi
> 
> It's a known issue[1], and we fixed it in SMX4 branch.
> If you are not comfortable with playing apache SNAPSHOT version, you can
> try out the coming up Fuse ESB 4.1.x monthly release version.
> 
> [1] http://fusesource.com/issues/browse/ESB-733
> 
> Willem
> 
-- 
View this message in context: http://www.nabble.com/How-do-i-use-a-JMS-Consumer-in-Camel-DSL--tp23997268p24029516.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do i use a JMS Consumer in Camel DSL?

Posted by Willem Jiang <wi...@gmail.com>.
Hi

It's a known issue[1], and we fixed it in SMX4 branch.
If you are not comfortable with playing apache SNAPSHOT version, you can
try out the coming up Fuse ESB 4.1.x monthly release version.

[1] http://fusesource.com/issues/browse/ESB-733

Willem

triggershot wrote:
> Hey,
> 
> i have the following problem. I've defined a JMS - Service Unit with a
> Provider and Consumer (like in the Tutorial "Camel" from
> servicemix.apache.org):
> 
> ######################################################
> <beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>        xmlns:tutorial="urn:org:apache:servicemix:tutorial:camel"
>        xmlns:amq="http://activemq.org/config/1.0">
>     <jms:provider service="tutorial:jms"
>                   endpoint="provider" 
>                   destinationName="tutorial.camel.queue"
>                   connectionFactory="#connectionFactory" />
>     <jms:consumer service="tutorial:jms"
> 	          endpoint="consumer"
> 	          destinationName="tutorial.camel.queue"
> 	          connectionFactory="#connectionFactory"
> 	          targetService="tutorial:jms"
> 	          targetEndpoint="consumer" />	
>      <amq:connectionFactory id="connectionFactory"
> brokerURL="tcp://localhost:61616" />
> </beans>
> ######################################################
> 
> 
> And here is my Camel MyRouteBuilder.java:
> 
> ######################################################
> public class MyRouteBuilder extends RouteBuilder 
> {
> public void configure() 
> {
>   from("timer://tutorial?fixedRate=true&delay=3000&period=10000")
>   .setBody(constant("<message>This is a  test</message>"))
>   .convertBodyTo(DOMSource.class)
>   .to("jbi:endpoint:urn:org:apache:servicemix:tutorial:camel:jms:provider");
> 	    	
>   from("jbi:endpoint:urn:org:apache:servicemix:tutorial:camel:jms:consumer")
>   .to("log:mylogger");
> }
> }
> ######################################################
> 
> 
> The message receives the provider. But my Consumer cannot "get" the message
> from the Queue. I get the following error:
> 
> ######################################################
> 13:35:09,500 | WARN  | nerContainer-498 | DefaultMessageListenerContainer  |
> AbstractMessageListenerContainer  646 | Execution of JMS message listener
> failed
> javax.jms.JMSException: Error sending JBI exchange
>         at
> org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:575)
>         at
> org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint$1.onMessage(JmsConsumerEndpoint.java:505)
>         at
> org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:518)
>         at
> org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:479)
>         at
> org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)
>         at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
>         at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
>         at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
>         at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
>         at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
>         at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.NullPointerException
>         at
> java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:881)
>         at
> org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.pending(AssemblyReferencesListener.java:110)
>         at
> org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.exchangeSent(AssemblyReferencesListener.java:98)
>         at
> org.apache.servicemix.nmr.core.ChannelImpl.dispatch(ChannelImpl.java:282)
>         at
> org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:141)
>         at
> org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:127)
>         at
> org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:187)
>         at
> org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:115)
>         at
> org.apache.servicemix.common.endpoints.SimpleEndpoint.sendSync(SimpleEndpoint.java:74)
>         at
> org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:548)
> ######################################################
> 
> What ' s the reason? I only want this:
> - write a Message to the JMS provider
> - JMS consumer polls the ActiveMQueue and if a message is incoming it writes
> the message-content back to the ServiceMix-Log.
> 
> Where is the error?