Re: Apache Camel 2.0 M1-java.lang.ClassCastException: org.apache.camel.component.jms.JmsConfiguration$CamelJmsTeemplate102

2009-03-24 Thread Claus Ibsen
Hi

I have had a quick look and it looks like a bug in Camel. I have
created a ticket for it
https://issues.apache.org/activemq/browse/CAMEL-1480

Not many uses the old 1.0.2 JMS API hence not discovered before.

If WebSphereMQ 5.3 support the new 1.1 JMS API then the MQ client
.jars you have on your classpath must also be JMS 1.1 ready.

But I will get a fix for the old 1.0.2 API. Then you can test it using
a 2.0-SNAPSHOT version.
See the Apache Camel downloads page for how to setup maven to look in
the Apache SNAPSHOT repo.




On Mon, Mar 23, 2009 at 7:56 PM, funkychap funkycha...@hotmail.com wrote:


 Hi,

 I only tried with camel 2. If you want me to try with lower versions, i
 can.Let me know.

 Thanks,

 Claus Ibsen-2 wrote:

 Hi

 The best solution would be if MQ can use JMS 1.1 api:
 You might need to setup the JMS connection factory in MQ to be JMS 1.1 as
 well.
 There might be some option in MQ somewhere to configure this.


 Did it work with Camel 1.x or have you only tried 2.0m1?

 I will look into this in the morning when I am at work again.
 Maybe there is something we can do in Camel to support good old IBM :)



 On Mon, Mar 23, 2009 at 7:33 PM, funkychap funkycha...@hotmail.com
 wrote:


 I got this when i tried it:

 2009-03-23 13:31:25,636 INFO
 [org.apache.camel.processor.interceptor.TraceInterceptor] -
 ID-W2GZHS8301-1159-1237833080668-2-0  direct:CustomerService --
 to(ibmmq://queue:My.QUEUE), Pattern:InOut,
 Headers:{content.type=text/xml,
 SOAPAction=}, BodyType:byte[], Body:soap:Envelope
 ./soap:Envelope
 Exception in thread main java.lang.AbstractMethodError:
 com.ibm.mq.jms.MQQueueConnectionFactory.createConnection()Ljavax/jms/Connection;
        at
 org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:378)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:346)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:258)
        at
 org.springframework.jms.listener.SimpleMessageListenerContainer.doStart(SimpleMessageListenerContainer.java:175)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.initialize(AbstractJmsListeningContainer.java:171)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.afterPropertiesSet(AbstractJmsListeningContainer.java:134)
        at
 org.apache.camel.component.jms.requestor.Requestor.doStart(Requestor.java:205)
        at

 Claus Ibsen-2 wrote:

 Hi

 Can you try with JMS 1.1?
 useVersion102=false



 On Mon, Mar 23, 2009 at 7:05 PM, funkychap funkycha...@hotmail.com
 wrote:

 HI,

 I am trying to run the example provided in the camel manual.

 Better JMS Transport for CXF Webservice using Apache Camel.

 I made changes to the connection factory to point to the iBM MQ 5.3. I
 changed the wsdl to my service wsdl. When i am trying to run, i am
 getting
 the exception:

 2009-03-23 12:18:09,322 ERROR
 [org.apache.camel.processor.DeadLetterChannel]
 - Failed delivery for exchangeId: ID-W2GZHS8301-4436-1237828678058-0-0.
 On
 delivery attempt: 5 caught: java.lang.ClassCastException:
 org.apache.camel.component.jms.JmsConfiguration$CamelJmsTeemplate102
 java.lang.ClassCastException:
 org.apache.camel.component.jms.JmsConfiguration$CamelJmsTeemplate102
        at
 org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:175)
        at
 org.apache.camel.processor.SendProcessor.process(SendProcessor.java:68)
        at
 org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:49)
        at
 org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:78)
        at
 org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:115)

 Any Ideas:

 My client.xml is listed below:
 bean id=ibmmq class=org.apache.camel.component.jms.JmsComponent
                property name=connectionFactory
                        bean
 class=com.ibm.mq.jms.MQQueueConnectionFactory
                                property name=transportType
                                        util:constant
 static-field=com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP/
                                /property
                                property name=queueManager
 value=QM_w2gzhs8301/
                                property name=hostName
 value=XXX.XXX.XX.XX/
                                property name=port value=1414/
                        /bean
                /property
                property name=useVersion102 value=true /
                !--property name=messageConverter
 ref=messageConverter102/

        --/bean

                bean id=messageConverter102
 class=org.springframework.jms.support.converter.SimpleMessageConverter102/

                

Re: Apache Camel 2.0 M1-java.lang.ClassCastException: org.apache.camel.component.jms.JmsConfiguration$CamelJmsTeemplate102

2009-03-24 Thread Claus Ibsen
Hi

I have committed a fix. So when a new 2.0-SNAPSHOT is build and
deployed on the maven repo, could you try it out?


On Tue, Mar 24, 2009 at 8:12 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 I have had a quick look and it looks like a bug in Camel. I have
 created a ticket for it
 https://issues.apache.org/activemq/browse/CAMEL-1480

 Not many uses the old 1.0.2 JMS API hence not discovered before.

 If WebSphereMQ 5.3 support the new 1.1 JMS API then the MQ client
 .jars you have on your classpath must also be JMS 1.1 ready.

 But I will get a fix for the old 1.0.2 API. Then you can test it using
 a 2.0-SNAPSHOT version.
 See the Apache Camel downloads page for how to setup maven to look in
 the Apache SNAPSHOT repo.




 On Mon, Mar 23, 2009 at 7:56 PM, funkychap funkycha...@hotmail.com wrote:


 Hi,

 I only tried with camel 2. If you want me to try with lower versions, i
 can.Let me know.

 Thanks,

 Claus Ibsen-2 wrote:

 Hi

 The best solution would be if MQ can use JMS 1.1 api:
 You might need to setup the JMS connection factory in MQ to be JMS 1.1 as
 well.
 There might be some option in MQ somewhere to configure this.


 Did it work with Camel 1.x or have you only tried 2.0m1?

 I will look into this in the morning when I am at work again.
 Maybe there is something we can do in Camel to support good old IBM :)



 On Mon, Mar 23, 2009 at 7:33 PM, funkychap funkycha...@hotmail.com
 wrote:


 I got this when i tried it:

 2009-03-23 13:31:25,636 INFO
 [org.apache.camel.processor.interceptor.TraceInterceptor] -
 ID-W2GZHS8301-1159-1237833080668-2-0  direct:CustomerService --
 to(ibmmq://queue:My.QUEUE), Pattern:InOut,
 Headers:{content.type=text/xml,
 SOAPAction=}, BodyType:byte[], Body:soap:Envelope
 ./soap:Envelope
 Exception in thread main java.lang.AbstractMethodError:
 com.ibm.mq.jms.MQQueueConnectionFactory.createConnection()Ljavax/jms/Connection;
        at
 org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:378)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:346)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:258)
        at
 org.springframework.jms.listener.SimpleMessageListenerContainer.doStart(SimpleMessageListenerContainer.java:175)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.initialize(AbstractJmsListeningContainer.java:171)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.afterPropertiesSet(AbstractJmsListeningContainer.java:134)
        at
 org.apache.camel.component.jms.requestor.Requestor.doStart(Requestor.java:205)
        at

 Claus Ibsen-2 wrote:

 Hi

 Can you try with JMS 1.1?
 useVersion102=false



 On Mon, Mar 23, 2009 at 7:05 PM, funkychap funkycha...@hotmail.com
 wrote:

 HI,

 I am trying to run the example provided in the camel manual.

 Better JMS Transport for CXF Webservice using Apache Camel.

 I made changes to the connection factory to point to the iBM MQ 5.3. I
 changed the wsdl to my service wsdl. When i am trying to run, i am
 getting
 the exception:

 2009-03-23 12:18:09,322 ERROR
 [org.apache.camel.processor.DeadLetterChannel]
 - Failed delivery for exchangeId: ID-W2GZHS8301-4436-1237828678058-0-0.
 On
 delivery attempt: 5 caught: java.lang.ClassCastException:
 org.apache.camel.component.jms.JmsConfiguration$CamelJmsTeemplate102
 java.lang.ClassCastException:
 org.apache.camel.component.jms.JmsConfiguration$CamelJmsTeemplate102
        at
 org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:175)
        at
 org.apache.camel.processor.SendProcessor.process(SendProcessor.java:68)
        at
 org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:49)
        at
 org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:78)
        at
 org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:115)

 Any Ideas:

 My client.xml is listed below:
 bean id=ibmmq class=org.apache.camel.component.jms.JmsComponent
                property name=connectionFactory
                        bean
 class=com.ibm.mq.jms.MQQueueConnectionFactory
                                property name=transportType
                                        util:constant
 static-field=com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP/
                                /property
                                property name=queueManager
 value=QM_w2gzhs8301/
                                property name=hostName
 value=XXX.XXX.XX.XX/
                                property name=port value=1414/
                        /bean
                /property
                property name=useVersion102 value=true /
                

Routing keeping originalMessageId

2009-03-24 Thread N.D.

Hi,

I encoutered some problem deploying a bridge between 2 jms brokers via
spring:

On one hand i have a public access jms broker (currently activemq 5.2.0)
accepting connections from many clients, each one working with a name
standardized set of queues.

On the other hand, i have a private jms broker (same activemq for easier
testing but will change soon) with only a common set of queues listened by
my asynchronous processor.

I want to use a camel route to concentrate every clients queues to the ones
of my private jms broker.
JMS Messages exchange works as follows:

In some cases, input messages doesn't expect reply (no replyTo set - so
InOnly camel speaking)
In other cases, input messages expect a reply (replyTo set) but depending on
input message content and security configuration on processor, those one
could never reply to requester (i quess it falls into the InOptionalOut
scheme)

Here's my initial configuration:

?xml version=1.0 encoding=UTF-8?
beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xmlns:amq=http://activemq.apache.org/schema/core;
xmlns:cml=http://activemq.apache.org/camel/schema/spring;
xmlns=http://www.springframework.org/schema/beans;
xsi:schemaLocation=http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd

http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd

http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring-1.5.0.xsd;

!-- - - - - - - - - - - - - - - - - - - - --
!--  PUBLIC BROKER CONFIGURATION  --
!-- - - - - - - - - - - - - - - - - - - - --

!-- The public broker --
bean id=public class=org.apache.camel.component.jms.JmsComponent
property name=configuration
bean 
class=org.apache.camel.component.jms.JmsConfiguration
property name=connectionFactory
amq:connectionFactory 
brokerURL=failover:tcp://localhost:61616

userName=public

password=toto/
/property
/bean
/property
/bean

!-- The private broker --
bean id=private class=org.apache.camel.component.jms.JmsComponent
property name=configuration
bean 
class=org.apache.camel.component.jms.JmsConfiguration
property name=connectionFactory
amq:connectionFactory 
brokerURL=failover:tcp://localhost:61617

userName=private

password=titi/
/property
/bean
/property
/bean

!-- My routing configuration --
cml:camelContext id=router
cml:route
cml:from uri=public:*.queues.in.*/
cml:to uri=private:private-queues.in.0/
/cml:route
/cml:camelContext

/beans

My problem is that when replyTo is set, camel expect a reply on dynamically
created temp queue which may never came-back or very late (due to
asynchronous processing), so dead letter and time out often occurs. I tried
to add exchangePattern=InOptionalOut on queues without success.

So i disable camel replyTo (via the disableReplyTo property) and manually
handle it. Input message are so considered as InOnly and my processor
directly reply setting correlationID as input messageid.

However, routing override incomings messageId so i produce replies with
wrong correlation id as explainded here:

client push message in public broker
 - public broker affect ID=1
  - camel route it to private broker which override ID to 2
   - so my processor listening private broker handle message
with ID=2 (producing correlation ID=2 against 1 desired)

I tried to set messageIdEnabled to false on private but it does works (i saw
activemq 5.2.0 uses camel 1.5.0 which had a bug on messageID copy solved in
later version so i have customized my active mq to use 1.6.0 but wihout
success)

Can someone help me to solve my problem ?

Thanks,
Nicolas

-- 
View this message in context: 
http://www.nabble.com/Routing-keeping-originalMessageId-tp22678749p22678749.html
Sent from the Camel - 

Re: Routing keeping originalMessageId

2009-03-24 Thread Claus Ibsen
Hi

Just a quick reply

1)
You can send a dummy NACK response when the client was not supposed to
get a response

2)
Camel 2.0 have better support for InOptionalOut, so if possible try
with 2.0. There is a 2.0m1 in the central maven repo.

3)
Who is overriding the correlation id? Is it the private broker or is
it Camel itself?




On Tue, Mar 24, 2009 at 12:45 PM, N.D. nicolas_dufai...@hotmail.com wrote:

 Hi,

 I encoutered some problem deploying a bridge between 2 jms brokers via
 spring:

 On one hand i have a public access jms broker (currently activemq 5.2.0)
 accepting connections from many clients, each one working with a name
 standardized set of queues.

 On the other hand, i have a private jms broker (same activemq for easier
 testing but will change soon) with only a common set of queues listened by
 my asynchronous processor.

 I want to use a camel route to concentrate every clients queues to the ones
 of my private jms broker.
 JMS Messages exchange works as follows:

 In some cases, input messages doesn't expect reply (no replyTo set - so
 InOnly camel speaking)
 In other cases, input messages expect a reply (replyTo set) but depending on
 input message content and security configuration on processor, those one
 could never reply to requester (i quess it falls into the InOptionalOut
 scheme)

 Here's my initial configuration:

 ?xml version=1.0 encoding=UTF-8?
 beans xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
                xmlns:amq=http://activemq.apache.org/schema/core;
                xmlns:cml=http://activemq.apache.org/camel/schema/spring;
                xmlns=http://www.springframework.org/schema/beans;
                xsi:schemaLocation=http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans.xsd
                                                        
 http://activemq.apache.org/schema/core
 http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd
                                                        
 http://activemq.apache.org/camel/schema/spring
 http://activemq.apache.org/camel/schema/spring/camel-spring-1.5.0.xsd;

        !-- - - - - - - - - - - - - - - - - - - - --
        !--      PUBLIC BROKER CONFIGURATION      --
        !-- - - - - - - - - - - - - - - - - - - - --

        !-- The public broker --
        bean id=public class=org.apache.camel.component.jms.JmsComponent
                property name=configuration
                        bean 
 class=org.apache.camel.component.jms.JmsConfiguration
                                property name=connectionFactory
                                        amq:connectionFactory 
 brokerURL=failover:tcp://localhost:61616
                                                                               
          userName=public
                                                                               
          password=toto/
                                /property
                        /bean
                /property
        /bean

        !-- The private broker --
        bean id=private class=org.apache.camel.component.jms.JmsComponent
                property name=configuration
                        bean 
 class=org.apache.camel.component.jms.JmsConfiguration
                                property name=connectionFactory
                                        amq:connectionFactory 
 brokerURL=failover:tcp://localhost:61617
                                                                               
          userName=private
                                                                               
          password=titi/
                                /property
                        /bean
                /property
        /bean

        !-- My routing configuration --
        cml:camelContext id=router
                cml:route
                        cml:from uri=public:*.queues.in.*/
                        cml:to uri=private:private-queues.in.0/
                /cml:route
        /cml:camelContext

 /beans

 My problem is that when replyTo is set, camel expect a reply on dynamically
 created temp queue which may never came-back or very late (due to
 asynchronous processing), so dead letter and time out often occurs. I tried
 to add exchangePattern=InOptionalOut on queues without success.

 So i disable camel replyTo (via the disableReplyTo property) and manually
 handle it. Input message are so considered as InOnly and my processor
 directly reply setting correlationID as input messageid.

 However, routing override incomings messageId so i produce replies with
 wrong correlation id as explainded here:

 client push message in public broker
     - public broker affect ID=1
          - camel route it to private broker which override ID to 2
               - so my processor listening private broker handle message
 with ID=2 (producing correlation ID=2 against 1 desired)

 I tried to set messageIdEnabled to false on private but it does 

Re: Non-Spring Transaction Manager

2009-03-24 Thread Colin Ruthven

Thanks. That got me further.

Assuming I use JOTM and use it for transaction control within Java, I 
attempted the following applicationContext.xml :


  context:component-scan base-package=org.apache.camel.spring.produce/
  camel:camelContext id=camel
  /camel:camelContext

 bean id=jotm 
class=org.springframework.transaction.jta.JotmFactoryBean/


 bean id=jtaTransactionManager 
class=org.springframework.transaction.jta.JtaTransactionManager

  property name=userTransactionref local=jotm//property
 /bean

   bean id=jmsConnectionFactory 
class=org.apache.activemq.spring.ActiveMQXAConnectionFactory  
   /bean
  
   bean id=jmsComponent 
class=org.apache.camel.component.jms.JmsComponent
   property name=transactionManagerref 
local=jtaTransactionManager//property

   property name=transacted value=true/
   property name=connectionFactoryref 
local=jmsConnectionFactory/ /property

   /bean

I have a unit test successfully sending and receiving to an ActiveMQ 
broker outside the VM.


To that test I created a JOTM TransactionManager, Transaction then 
prefixed the producer.sendBody() with a begin transaction and followed 
the send with a rollback.

The message still gets sent.

By the looks of stdout Spring is finding the JTA and JOTM is starting.

I'm using Camel 1.6 and ActiveMQ 5.2

What am I missing?

Thanks,
Colin

James Strachan wrote:

2009/3/23 Colin Ruthven ruth...@attglobal.net:
  

I don't specifically have one in mind.

In exploring Camel I found that one can perform the basic messaging
functions in Java using Camel API's only but got messy with transactions.

My preference would be for Camel to expose a JTA. If that transparently
invoked Spring TX that would be fine - analogous to the various components
wrapping Spring but not exposing it directly in Java.



BTW you can ignore the Spring IoC stuff if you like and just use Java
to wire stuff together and populate JNDI - or use Guice or whatever.


  

What other options exist outside a container (or inside) for transaction
support that would work with Camel?



The JMS component  endpoints relies on the Spring JMS abstractions
(JmsTemplate and MessageListenerContainer classes) which use Spring
transactions under the covers. However its pretty trivial to configure
the JmsComponent to use Spring's JtaTransactionManager then you can do
whatever you like with JTA and all the JMS endpoints will be
auto-enlisted in JTA for you.

However one of the main benefits of the spring transactions support
(other than the proxy/aop/annotation stuff) is that its trivial to
switch between XA/JTA and  lightweight transactions (e.g. pure JMS
transactions or pure JDBC transactions) without the J2EE Transaction
Manager / JCA / XA overhead.

  


Re: Non-Spring Transaction Manager

2009-03-24 Thread James Strachan
Whats the code using the producer look like?

2009/3/24 Colin Ruthven ruth...@attglobal.net:
 Thanks. That got me further.

 Assuming I use JOTM and use it for transaction control within Java, I
 attempted the following applicationContext.xml :

  context:component-scan base-package=org.apache.camel.spring.produce/
  camel:camelContext id=camel
  /camel:camelContext

  bean id=jotm
 class=org.springframework.transaction.jta.JotmFactoryBean/

  bean id=jtaTransactionManager
 class=org.springframework.transaction.jta.JtaTransactionManager
      property name=userTransactionref local=jotm//property
  /bean

   bean id=jmsConnectionFactory
 class=org.apache.activemq.spring.ActiveMQXAConnectionFactory
 /bean
     bean id=jmsComponent
 class=org.apache.camel.component.jms.JmsComponent
       property name=transactionManagerref
 local=jtaTransactionManager//property
       property name=transacted value=true/
       property name=connectionFactoryref local=jmsConnectionFactory/
 /property
   /bean

 I have a unit test successfully sending and receiving to an ActiveMQ broker
 outside the VM.

 To that test I created a JOTM TransactionManager, Transaction then prefixed
 the producer.sendBody() with a begin transaction and followed the send with
 a rollback.
 The message still gets sent.

 By the looks of stdout Spring is finding the JTA and JOTM is starting.

 I'm using Camel 1.6 and ActiveMQ 5.2

 What am I missing?

 Thanks,
 Colin

 James Strachan wrote:

 2009/3/23 Colin Ruthven ruth...@attglobal.net:


 I don't specifically have one in mind.

 In exploring Camel I found that one can perform the basic messaging
 functions in Java using Camel API's only but got messy with transactions.

 My preference would be for Camel to expose a JTA. If that transparently
 invoked Spring TX that would be fine - analogous to the various
 components
 wrapping Spring but not exposing it directly in Java.


 BTW you can ignore the Spring IoC stuff if you like and just use Java
 to wire stuff together and populate JNDI - or use Guice or whatever.




 What other options exist outside a container (or inside) for transaction
 support that would work with Camel?


 The JMS component  endpoints relies on the Spring JMS abstractions
 (JmsTemplate and MessageListenerContainer classes) which use Spring
 transactions under the covers. However its pretty trivial to configure
 the JmsComponent to use Spring's JtaTransactionManager then you can do
 whatever you like with JTA and all the JMS endpoints will be
 auto-enlisted in JTA for you.

 However one of the main benefits of the spring transactions support
 (other than the proxy/aop/annotation stuff) is that its trivial to
 switch between XA/JTA and  lightweight transactions (e.g. pure JMS
 transactions or pure JDBC transactions) without the J2EE Transaction
 Manager / JCA / XA overhead.






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

Open Source Integration
http://fusesource.com/


Re: Non-Spring Transaction Manager

2009-03-24 Thread Colin Ruthven

Thought you'd ask. :)
It reflects some exploration of a couple of Camel API's, rather than 
being stripped to a minimum.


Thanks again for helping.
Colin

public class DataCamelTest extends TestCase{
   CamelContext context;

   ProducerTemplate prod;
   Endpoint end;
  
   public DataCamelTest(String arg0) {

   super(arg0);
   }

   protected void setUp() throws Exception {
   super.setUp();
  
   context = new DefaultCamelContext();

   context.start();
   context.addComponent(activemq,
   ActiveMQComponent.activeMQComponent(tcp://localhost:61616));

   prod = new DefaultProducerTemplateExchange(context);
   end = context.getComponent(activemq).createEndpoint(TEST.FOO);
   context.addEndpoint(end, end );
   }

   public void testProcess() throws InterruptedException {
   //System.out.println(producer);
   //assertTrue(producer!=null);

   ApplicationContext spring = new 
ClassPathXmlApplicationContext(applicationContext.xml);
   JtaTransactionManager transactionManager = 
(JtaTransactionManager) spring.getBean(jtaTransactionManager);
   ((JmsComponent) 
context.getComponent(activemq)).getConfiguration().setTransactionManager(transactionManager);
   ((JmsComponent) 
context.getComponent(activemq)).getConfiguration().setTransacted(true);


   Transaction tx = null;
   Jotm jotm = null;
   TransactionManager tm = null;
   try {
   jotm = new Jotm(true, false);
   tm = jotm.getTransactionManager();
   tm.begin();   
  
   prod.sendBody( activemq:TEST.FOO, Hello);

   prod.sendBody( end, Hello1);

   tm.rollback();

   } catch (IllegalStateException e1) {
   e1.printStackTrace();
   } catch (SystemException e1) {
   e1.printStackTrace();
   } catch (NamingException e) {
   e.printStackTrace();
   } catch (NotSupportedException e) {
   e.printStackTrace();
   }
  
   Endpoint endpoint = context.getEndpoint(activemq:TEST.FOO);

   Consumer consumer = null;

   Processor my = new MyProcessor();
   try {
   consumer = endpoint.createConsumer(my);
   consumer.start(); 
   } catch (Exception e) {

   e.printStackTrace();
   }
  
   try {

   Thread.sleep(100);
   } catch (InterruptedException e) {
   e.printStackTrace();
   }
   }

   public static class MyProcessor implements Processor {
   private int count;
   public void process(Exchange exchange) throws Exception {
  
 Message message = exchange.getIn();
 System.out.println(message.getBody());   
   }

   }
}


James Strachan wrote:

Whats the code using the producer look like?

2009/3/24 Colin Ruthven ruth...@attglobal.net:
  

Thanks. That got me further.

Assuming I use JOTM and use it for transaction control within Java, I
attempted the following applicationContext.xml :

 context:component-scan base-package=org.apache.camel.spring.produce/
 camel:camelContext id=camel
 /camel:camelContext

 bean id=jotm
class=org.springframework.transaction.jta.JotmFactoryBean/

 bean id=jtaTransactionManager
class=org.springframework.transaction.jta.JtaTransactionManager
 property name=userTransactionref local=jotm//property
 /bean

  bean id=jmsConnectionFactory
class=org.apache.activemq.spring.ActiveMQXAConnectionFactory
/bean
bean id=jmsComponent
class=org.apache.camel.component.jms.JmsComponent
  property name=transactionManagerref
local=jtaTransactionManager//property
  property name=transacted value=true/
  property name=connectionFactoryref local=jmsConnectionFactory/
/property
  /bean

I have a unit test successfully sending and receiving to an ActiveMQ broker
outside the VM.

To that test I created a JOTM TransactionManager, Transaction then prefixed
the producer.sendBody() with a begin transaction and followed the send with
a rollback.
The message still gets sent.

By the looks of stdout Spring is finding the JTA and JOTM is starting.

I'm using Camel 1.6 and ActiveMQ 5.2

What am I missing?

Thanks,
Colin

James Strachan wrote:


2009/3/23 Colin Ruthven ruth...@attglobal.net:

  

I don't specifically have one in mind.

In exploring Camel I found that one can perform the basic messaging
functions in Java using Camel API's only but got messy with transactions.

My preference would be for Camel to expose a JTA. If that transparently
invoked Spring TX that would be fine - analogous to the various
components
wrapping Spring but not exposing it directly in Java.



BTW you can ignore the Spring IoC stuff if you like and just use Java
to wire stuff together and populate JNDI - or use Guice or whatever.



  

What other options exist outside a container (or inside) for transaction
support that would work with Camel?



The JMS component  endpoints relies on the Spring JMS 

Re: Non-Spring Transaction Manager

2009-03-24 Thread James Strachan
2009/3/24 James Strachan james.strac...@gmail.com:
 I think the issue is that you configure the configuration of the JMS
 component with the transaction manager after you've created the JMS
 endpoint. Try moving the configuration of the JMS component to the
 setup method; before you create any endpoints?

Just for some background; when you create a JmsEndpoint it takes its
own copy of the JmsConfiguration bean so that you can then configure
the JmsEndpoint to your hearts content - but you don't necesarily
reconfigure other JMS endpoints
-- 
James
---
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/


Re: Delayer: Transport disposed at JVM-Shutdown

2009-03-24 Thread Markus Reil

Hi,

thanks for your help.
But I am still experiencing the same problem. The sleep does not get
interrupted (2.0-M1).
Do you have any idea why this happens? Let me know if you need more
information.

Thanks,
Markus
-- 
View this message in context: 
http://www.nabble.com/Delayer%3A-%22Transport-disposed%22-at-JVM-Shutdown-tp22202167p22681944.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.



Camel 2 - Spring DSL - setHeader / Constant (error)

2009-03-24 Thread cmoulliard

Hi,

I have use in my camel route (described using spring DSL), the following
syntax to define the header of my message :

setHeader headerName=origin
constantfile/constant
/setHeader

as described on the wiki site (http://camel.apache.org/constant.html) 

But, when I start my bundle on SMX4, I receive the error :

16:15:27,750 | ERROR | xtenderThread-21 | ContextLoaderListener|
BundleApplicationContextListener   50 | Application context refresh failed
(OsgiBundleXmlApplicationContext(bundle=reportincident.routing,
config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line
53 in XML document from URL
[bundle://116.0:0/META-INF/spring/camel-context.xml] is invalid; nested
exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid
content was found starting with element 'constant'. One of
'{http://camel.apache.org/schema/spring:description,
http://camel.apache.org/schema/spring:expressionDefinition,
http://camel.apache.org/schema/spring:constant,
http://camel.apache.org/schema/spring:el,
http://camel.apache.org/schema/spring:groovy,
http://camel.apache.org/schema/spring:header,
http://camel.apache.org/schema/spring:jxpath,
http://camel.apache.org/schema/spring:javaScript,
http://camel.apache.org/schema/spring:language,
http://camel.apache.org/schema/spring:method,
http://camel.apache.org/schema/spring:mvel,
http://camel.apache.org/schema/spring:ognl,
http://camel.apache.org/schema/spring:php,
http://camel.apache.org/schema/spring:property,
http://camel.apache.org/schema/spring:python,
http://camel.apache.org/schema/spring:ruby,
http://camel.apache.org/schema/spring:simple,
http://camel.apache.org/schema/spring:sql,
http://camel.apache.org/schema/spring:tokenize,
http://camel.apache.org/schema/spring:xpath,
http://camel.apache.org/schema/spring:xquery}' is expected.
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at
org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:176)
at
org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:142)
at
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$800(AbstractDelegatedExecutionApplicationContext.java:69)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:269)
at
org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:247)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:222)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:175)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)
at
org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)
at java.lang.Thread.run(Thread.java:619)

Regards, 

-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/Camel-2---Spring-DSL---setHeader---Constant-%28error%29-tp22682794p22682794.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Camel 2 - Spring DSL - setHeader / Constant (error)

2009-03-24 Thread cmoulliard

Forget my post. My bundle on SMX4 was not updated correctly.

Everything is OK.


cmoulliard wrote:
 
 Hi,
 
 I have use in my camel route (described using spring DSL), the following
 syntax to define the header of my message :
 
   setHeader headerName=origin
   constantfile/constant
   /setHeader
 
 as described on the wiki site (http://camel.apache.org/constant.html) 
 
 But, when I start my bundle on SMX4, I receive the error :
 
 16:15:27,750 | ERROR | xtenderThread-21 | ContextLoaderListener   
 | BundleApplicationContextListener   50 | Application context refresh
 failed (OsgiBundleXmlApplicationContext(bundle=reportincident.routing,
 config=osgibundle:/META-INF/spring/*.xml))
 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
 Line 53 in XML document from URL
 [bundle://116.0:0/META-INF/spring/camel-context.xml] is invalid; nested
 exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a:
 Invalid content was found starting with element 'constant'. One of
 '{http://camel.apache.org/schema/spring:description,
 http://camel.apache.org/schema/spring:expressionDefinition,
 http://camel.apache.org/schema/spring:constant,
 http://camel.apache.org/schema/spring:el,
 http://camel.apache.org/schema/spring:groovy,
 http://camel.apache.org/schema/spring:header,
 http://camel.apache.org/schema/spring:jxpath,
 http://camel.apache.org/schema/spring:javaScript,
 http://camel.apache.org/schema/spring:language,
 http://camel.apache.org/schema/spring:method,
 http://camel.apache.org/schema/spring:mvel,
 http://camel.apache.org/schema/spring:ognl,
 http://camel.apache.org/schema/spring:php,
 http://camel.apache.org/schema/spring:property,
 http://camel.apache.org/schema/spring:python,
 http://camel.apache.org/schema/spring:ruby,
 http://camel.apache.org/schema/spring:simple,
 http://camel.apache.org/schema/spring:sql,
 http://camel.apache.org/schema/spring:tokenize,
 http://camel.apache.org/schema/spring:xpath,
 http://camel.apache.org/schema/spring:xquery}' is expected.
   at
 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
   at
 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
   at
 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
   at
 org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
   at
 org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
   at
 org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
   at
 org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:176)
   at
 org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:142)
   at
 org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
   at
 org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
   at
 org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$800(AbstractDelegatedExecutionApplicationContext.java:69)
   at
 org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:269)
   at
 org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
   at
 org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:247)
   at
 org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:222)
   at
 org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:175)
   at
 org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)
   at
 org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)
   at java.lang.Thread.run(Thread.java:619)
 
 Regards, 
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 

Re: Apache Camel 2.0 M1-java.lang.ClassCastException: org.apache.camel.component.jms.JmsConfiguration$CamelJmsTeemplate102

2009-03-24 Thread funkychap

I installed the CSD14 patch for MQ5.3 and added the new MQ jars to the
project and i no longer get the exception.



Thanks,

Claus Ibsen-2 wrote:
 
 Hi
 
 I have committed a fix. So when a new 2.0-SNAPSHOT is build and
 deployed on the maven repo, could you try it out?
 
 
 On Tue, Mar 24, 2009 at 8:12 AM, Claus Ibsen claus.ib...@gmail.com
 wrote:
 Hi

 I have had a quick look and it looks like a bug in Camel. I have
 created a ticket for it
 https://issues.apache.org/activemq/browse/CAMEL-1480

 Not many uses the old 1.0.2 JMS API hence not discovered before.

 If WebSphereMQ 5.3 support the new 1.1 JMS API then the MQ client
 .jars you have on your classpath must also be JMS 1.1 ready.

 But I will get a fix for the old 1.0.2 API. Then you can test it using
 a 2.0-SNAPSHOT version.
 See the Apache Camel downloads page for how to setup maven to look in
 the Apache SNAPSHOT repo.




 On Mon, Mar 23, 2009 at 7:56 PM, funkychap funkycha...@hotmail.com
 wrote:


 Hi,

 I only tried with camel 2. If you want me to try with lower versions, i
 can.Let me know.

 Thanks,

 Claus Ibsen-2 wrote:

 Hi

 The best solution would be if MQ can use JMS 1.1 api:
 You might need to setup the JMS connection factory in MQ to be JMS 1.1
 as
 well.
 There might be some option in MQ somewhere to configure this.


 Did it work with Camel 1.x or have you only tried 2.0m1?

 I will look into this in the morning when I am at work again.
 Maybe there is something we can do in Camel to support good old IBM :)



 On Mon, Mar 23, 2009 at 7:33 PM, funkychap funkycha...@hotmail.com
 wrote:


 I got this when i tried it:

 2009-03-23 13:31:25,636 INFO
 [org.apache.camel.processor.interceptor.TraceInterceptor] -
 ID-W2GZHS8301-1159-1237833080668-2-0  direct:CustomerService --
 to(ibmmq://queue:My.QUEUE), Pattern:InOut,
 Headers:{content.type=text/xml,
 SOAPAction=}, BodyType:byte[], Body:soap:Envelope
 ./soap:Envelope
 Exception in thread main java.lang.AbstractMethodError:
 com.ibm.mq.jms.MQQueueConnectionFactory.createConnection()Ljavax/jms/Connection;
        at
 org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:378)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:346)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:258)
        at
 org.springframework.jms.listener.SimpleMessageListenerContainer.doStart(SimpleMessageListenerContainer.java:175)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.initialize(AbstractJmsListeningContainer.java:171)
        at
 org.springframework.jms.listener.AbstractJmsListeningContainer.afterPropertiesSet(AbstractJmsListeningContainer.java:134)
        at
 org.apache.camel.component.jms.requestor.Requestor.doStart(Requestor.java:205)
        at

 Claus Ibsen-2 wrote:

 Hi

 Can you try with JMS 1.1?
 useVersion102=false



 On Mon, Mar 23, 2009 at 7:05 PM, funkychap funkycha...@hotmail.com
 wrote:

 HI,

 I am trying to run the example provided in the camel manual.

 Better JMS Transport for CXF Webservice using Apache Camel.

 I made changes to the connection factory to point to the iBM MQ 5.3.
 I
 changed the wsdl to my service wsdl. When i am trying to run, i am
 getting
 the exception:

 2009-03-23 12:18:09,322 ERROR
 [org.apache.camel.processor.DeadLetterChannel]
 - Failed delivery for exchangeId:
 ID-W2GZHS8301-4436-1237828678058-0-0.
 On
 delivery attempt: 5 caught: java.lang.ClassCastException:
 org.apache.camel.component.jms.JmsConfiguration$CamelJmsTeemplate102
 java.lang.ClassCastException:
 org.apache.camel.component.jms.JmsConfiguration$CamelJmsTeemplate102
        at
 org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:175)
        at
 org.apache.camel.processor.SendProcessor.process(SendProcessor.java:68)
        at
 org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:49)
        at
 org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:78)
        at
 org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:115)

 Any Ideas:

 My client.xml is listed below:
 bean id=ibmmq
 class=org.apache.camel.component.jms.JmsComponent
                property name=connectionFactory
                        bean
 class=com.ibm.mq.jms.MQQueueConnectionFactory
                                property name=transportType
                                        util:constant
 static-field=com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP/
                                /property
                                property name=queueManager
 value=QM_w2gzhs8301/
                                property name=hostName
 value=XXX.XXX.XX.XX/
                                

Deploying same camelContext.xml in and out of OSGi

2009-03-24 Thread Aaron Crickenberger
I have the following XML I'd like to deploy both in an OSGi container, and a
non-OSGi container.  To deploy in the OSGi container, I have to use the
osgi schema so that the quartz component is resolved to the camel-quartz
bundle.

To deploy in a non-OSGi container, I had to add spring-osgi-core-1.1.2.jar
and org.osg.core-1.2.0.jar to the classpath.  It appears to be working, but
I wanted to double-check with the experts.  Can you think of any
side-effects I might see from deploying this way vs. deploying w/ the 
http://activemq.apache.org/camel/schema/spring; schema?

beans xmlns=http://www.springframework.org/schema/beans;
   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
   xmlns:camel=http://activemq.apache.org/camel/schema/spring;
   xsi:schemaLocation=
   http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
   http://activemq.apache.org/camel/schema/osgi
http://activemq.apache.org/camel/schema/osgi/camel-osgi.xsd;

  camelContext xmlns=http://activemq.apache.org/camel/schema/osgi;
camel:route
  camel:from uri=quartz://groupName/timerName/0,15,30,45/*/*/*/*/$ /
  camel:to uri=log:ExampleRouter/
/camel:route
  /camelContext

/beans

- aaron


Re: Delayer: Transport disposed at JVM-Shutdown

2009-03-24 Thread Claus Ibsen
On Tue, Mar 24, 2009 at 3:42 PM, Markus Reil gistenju...@gmx.de wrote:

 Hi,

 thanks for your help.
 But I am still experiencing the same problem. The sleep does not get
 interrupted (2.0-M1).
 Do you have any idea why this happens? Let me know if you need more
 information.
Can you show the complete route? And point out where the message is
when you shutdown.



 Thanks,
 Markus
 --
 View this message in context: 
 http://www.nabble.com/Delayer%3A-%22Transport-disposed%22-at-JVM-Shutdown-tp22202167p22681944.html
 Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.





-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/