You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by pwanner <pw...@pwanner.com> on 2011/07/12 11:27:10 UTC

Problem with ActiveMQ to Weblogic route

Hi everybody,

I'm having trouble with a Camel route from ActiveMq to Weblogic.

The use case is very simple, I have a Tomcat and an ActiveMq instance on the
same server.
The application in Tomcat is posting in the local ActiveMQ and the Camel
route is forwarding the message to the queue in Weblogic on a different
server.

Every time a message is posted this exception appears in the log:

org.springframework.jms.UncategorizedJmsException: Uncategorized exception
occured during JMS processing; nested exception is javax.jms.JMSException:
Could no disambiguate on queue|Topic-name totransform pollymorphic
destination into a ActiveMQ destination: testjmsmodule!ToActiveMq
at
org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
at
org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:469)
at
org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:170)
at org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:355)
at
org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:309)
at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:99)
...


Despite the exception the message is delivered is the Weblogic ToActiveMq
queue, but as I need to switch now to a transactional delivery, the message
is will be rollbacked.

Any idea what this error comes from?


Below is my camel.xml config (using ActiveMQ 5.5.0, Camel 2.7.0 and Weblogic
9.2):
  
  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
      <route>
          <from uri="activemq:queue:to.weblogic"/>
          <to uri="weblogic:queue:ToActiveMq"/>
      </route>
  </camelContext>
  
  <bean id="weblogic" class="org.apache.camel.component.jms.JmsComponent">
      <property name="connectionFactory" ref="weblogicConnectionFactory"/>
      <property name="destinationResolver"
ref="weblogicDestinationResolver"/>
  </bean>

  <bean id="weblogicDestinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
      <property name="jndiTemplate" ref="remoteJndi" /> 
  </bean>

  <bean id="weblogicConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiTemplate" ref="remoteJndi" />
      <property name="jndiName" value="weblogic.jms.ConnectionFactory" />
  </bean>

  <bean id="remoteJndi" class="org.springframework.jndi.JndiTemplate"> 
      <property name="environment"> 
          <props> 
              <prop
key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop> 
              <prop key="java.naming.provider.url">t3://host:7004</prop>
          </props>
      </property> 
   </bean>    

  <bean id="activemqTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
      <property name="connectionFactory" ref="activemqConnectionFactory" />
  </bean>

  <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent" >
      <property name="connectionFactory" ref="activemqConnectionFactory"/>
  </bean>
  
  <bean id="activemqConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
      <property name="brokerURL" value="tcp://localhost:8016" />
  </bean>


--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-ActiveMQ-to-Weblogic-route-tp4578300p4578300.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with ActiveMQ to Weblogic route

Posted by pwanner <pw...@pwanner.com>.
The jira  http://issues.apache.org/jira/browse/AMQ-3401 issue  has been
created.

Thank you all for your help.


--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-ActiveMQ-to-Weblogic-route-tp4578300p4590649.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with ActiveMQ to Weblogic route

Posted by Gary Tully <ga...@gmail.com>.
It makes sense to fix it up such that it can work in your case and I
guess to future proof it a bit.
The solution may be to make it configurable or plugable, adding a
fallback transformer implementation that can be delegated to in this
case.

I imagine a new public static
ActiveMQDestination.setFallbackTransformer() with something that
implements
  public ActiveMQDestination transform(Destination dest) throws JMSException

Can you raise a jira issue against activemq to track this?

On 14 July 2011 12:35, pwanner <pw...@pwanner.com> wrote:
> Yes this class is part of activemq-core-5.5.0.jar.
>
> I did a modification that works correctly reflecting the Destination
> parameter to check if in the case of weblogic.jms.common.DestinationImpl is
> has the isQueue and isTopic methods that could help to determine between
> Queue and Topic.
>
> As the problem is closely related to a Weblogic implementation class, I'm
> not sure that ActiveMQ would like to embed it in its distribution, even that
> using reflection avoid having a dependency to the Weblogic jar.
>
>
> The modification is in bold below:
>
>    public static ActiveMQDestination transform(Destination dest) throws
> JMSException {
>        if (dest == null) {
>            return null;
>        }
>        if (dest instanceof ActiveMQDestination) {
>            return (ActiveMQDestination)dest;
>        }
>
>        if (dest instanceof Queue && dest instanceof Topic) {
>            String queueName = ((Queue) dest).getQueueName();
>            String topicName = ((Topic) dest).getTopicName();
>
>            if (queueName != null && topicName == null) {
>                return new ActiveMQQueue(queueName);
>            } else if (queueName == null && topicName != null) {
>                return new ActiveMQTopic(topicName);
>            }
>
> *
>            Method isQueueMethod = null;
>            Method isTopicMethod = null;
>            try {
>                isQueueMethod = dest.getClass().getMethod("isQueue");
>                isTopicMethod = dest.getClass().getMethod("isTopic");
>                Boolean isQueue = (Boolean)isQueueMethod.invoke(dest);
>                Boolean isTopic = (Boolean)isTopicMethod.invoke(dest);
>                if(isQueue) {
>                    return new ActiveMQQueue(queueName);
>                } else if(isTopic){
>                    return new ActiveMQTopic(topicName);
>                }
>            } catch (Exception e) {}
> *
>          throw new JMSException("Could no disambiguate on queue|Topic-name
> totransform pollymorphic destination into a ActiveMQ destination: " + dest);
>        }
>        if (dest instanceof TemporaryQueue) {
>            return new
> ActiveMQTempQueue(((TemporaryQueue)dest).getQueueName());
>        }
>        if (dest instanceof TemporaryTopic) {
>            return new
> ActiveMQTempTopic(((TemporaryTopic)dest).getTopicName());
>        }
>        if (dest instanceof Queue) {
>            return new ActiveMQQueue(((Queue)dest).getQueueName());
>        }
>        if (dest instanceof Topic) {
>            return new ActiveMQTopic(((Topic)dest).getTopicName());
>        }
>        throw new JMSException("Could not transform the destination into a
> ActiveMQ destination: " + dest);
>    }
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-ActiveMQ-to-Weblogic-route-tp4578300p4586327.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
http://fusesource.com
http://blog.garytully.com

Re: Problem with ActiveMQ to Weblogic route

Posted by pwanner <pw...@pwanner.com>.
Yes this class is part of activemq-core-5.5.0.jar.

I did a modification that works correctly reflecting the Destination
parameter to check if in the case of weblogic.jms.common.DestinationImpl is
has the isQueue and isTopic methods that could help to determine between
Queue and Topic.

As the problem is closely related to a Weblogic implementation class, I'm
not sure that ActiveMQ would like to embed it in its distribution, even that
using reflection avoid having a dependency to the Weblogic jar.


The modification is in bold below:

    public static ActiveMQDestination transform(Destination dest) throws
JMSException {
        if (dest == null) {
            return null;
        }
        if (dest instanceof ActiveMQDestination) {
            return (ActiveMQDestination)dest;
        }
        
        if (dest instanceof Queue && dest instanceof Topic) {
            String queueName = ((Queue) dest).getQueueName();
            String topicName = ((Topic) dest).getTopicName();

            if (queueName != null && topicName == null) {
                return new ActiveMQQueue(queueName);
            } else if (queueName == null && topicName != null) {
                return new ActiveMQTopic(topicName);
            }
            
*            
            Method isQueueMethod = null;
            Method isTopicMethod = null;
            try {
                isQueueMethod = dest.getClass().getMethod("isQueue");
                isTopicMethod = dest.getClass().getMethod("isTopic");
                Boolean isQueue = (Boolean)isQueueMethod.invoke(dest);
                Boolean isTopic = (Boolean)isTopicMethod.invoke(dest);
                if(isQueue) {
                    return new ActiveMQQueue(queueName);
                } else if(isTopic){
                    return new ActiveMQTopic(topicName);
                }
            } catch (Exception e) {}
*
          throw new JMSException("Could no disambiguate on queue|Topic-name
totransform pollymorphic destination into a ActiveMQ destination: " + dest);
        }
        if (dest instanceof TemporaryQueue) {
            return new
ActiveMQTempQueue(((TemporaryQueue)dest).getQueueName());
        }
        if (dest instanceof TemporaryTopic) {
            return new
ActiveMQTempTopic(((TemporaryTopic)dest).getTopicName());
        }
        if (dest instanceof Queue) {
            return new ActiveMQQueue(((Queue)dest).getQueueName());
        }
        if (dest instanceof Topic) {
            return new ActiveMQTopic(((Topic)dest).getTopicName());
        }
        throw new JMSException("Could not transform the destination into a
ActiveMQ destination: " + dest);
    }

--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-ActiveMQ-to-Weblogic-route-tp4578300p4586327.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with ActiveMQ to Weblogic route

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jul 13, 2011 at 2:26 PM, pwanner <pw...@pwanner.com> wrote:
> Thank you for your answer Ashwin.
>
> Actualy I found from where the error comes :
>
> The JNDI lookup to Weblogic return a weblogic.jms.common.DestinationImpl
> instance that is the Weblogic generic implementation for Queue and Topic.
>
> In the org.apache.activemq.command.ActiveMQDestination class the transform()
> method can obtain both a queue name and a topic name and therefore doesn't
> know in witch one to cast.
>
> The Weblogic impl has two methods isQueue() and isTopic() for that.
>
> But now I have no idea for any workaround.
> Any help would be appreciated...
>

Is the code below from ActiveMQ? You may suggest a patch and submit it
to the JIRA at AcitveMQ.


>
> See the ActiveMQDestination class code below
>
>    public static ActiveMQDestination transform(Destination dest) throws
> JMSException {
>        if (dest == null) {
>            return null;
>        }
>        if (dest instanceof ActiveMQDestination) {
>            return (ActiveMQDestination)dest;
>        }
>
>        if (dest instanceof Queue && dest instanceof Topic) {
>            *String queueName = ((Queue) dest).getQueueName();
>            String topicName = ((Topic) dest).getTopicName();*
>           if (queueName != null && topicName == null) {
>                return new ActiveMQQueue(queueName);
>            } else if (queueName == null && topicName != null) {
>                return new ActiveMQTopic(topicName);
>            }
>            throw new JMSException("Could no disambiguate on
> queue|Topic-name totransform pollymorphic destination into a ActiveMQ
> destination: " + dest);
>        }
>        if (dest instanceof TemporaryQueue) {
>            return new
> ActiveMQTempQueue(((TemporaryQueue)dest).getQueueName());
>        }
>        if (dest instanceof TemporaryTopic) {
>            return new
> ActiveMQTempTopic(((TemporaryTopic)dest).getTopicName());
>        }
>        if (dest instanceof Queue) {
>            return new ActiveMQQueue(((Queue)dest).getQueueName());
>        }
>        if (dest instanceof Topic) {
>            return new ActiveMQTopic(((Topic)dest).getTopicName());
>        }
>        throw new JMSException("Could not transform the destination into a
> ActiveMQ destination: " + dest);
>    }
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-ActiveMQ-to-Weblogic-route-tp4578300p4582476.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Problem with ActiveMQ to Weblogic route

Posted by pwanner <pw...@pwanner.com>.
Thank you for your answer Ashwin.

Actualy I found from where the error comes :

The JNDI lookup to Weblogic return a weblogic.jms.common.DestinationImpl
instance that is the Weblogic generic implementation for Queue and Topic.

In the org.apache.activemq.command.ActiveMQDestination class the transform()
method can obtain both a queue name and a topic name and therefore doesn't
know in witch one to cast.

The Weblogic impl has two methods isQueue() and isTopic() for that.

But now I have no idea for any workaround.
Any help would be appreciated...


See the ActiveMQDestination class code below

    public static ActiveMQDestination transform(Destination dest) throws
JMSException {
        if (dest == null) {
            return null;
        }
        if (dest instanceof ActiveMQDestination) {
            return (ActiveMQDestination)dest;
        }
        
        if (dest instanceof Queue && dest instanceof Topic) {
            *String queueName = ((Queue) dest).getQueueName();
            String topicName = ((Topic) dest).getTopicName();* 
           if (queueName != null && topicName == null) {
                return new ActiveMQQueue(queueName);
            } else if (queueName == null && topicName != null) {
                return new ActiveMQTopic(topicName);
            }
            throw new JMSException("Could no disambiguate on
queue|Topic-name totransform pollymorphic destination into a ActiveMQ
destination: " + dest);
        }
        if (dest instanceof TemporaryQueue) {
            return new
ActiveMQTempQueue(((TemporaryQueue)dest).getQueueName());
        }
        if (dest instanceof TemporaryTopic) {
            return new
ActiveMQTempTopic(((TemporaryTopic)dest).getTopicName());
        }
        if (dest instanceof Queue) {
            return new ActiveMQQueue(((Queue)dest).getQueueName());
        }
        if (dest instanceof Topic) {
            return new ActiveMQTopic(((Topic)dest).getTopicName());
        }
        throw new JMSException("Could not transform the destination into a
ActiveMQ destination: " + dest);
    }


--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-ActiveMQ-to-Weblogic-route-tp4578300p4582476.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with ActiveMQ to Weblogic route

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

Looking at the stack trace, the error seems to be in the JMSProducer
attempting to send a message to a weblogic destination called toActiveMQ.

I am no weblogic expert, but I sense that the problem is in the
connectionFactory configuration and the associated connection. The
connectionFactory uses a JNDI based DestinationResolver and a JMS Template
in order to retrieve a connectionFactory and then create a connection. I
believe there is some duplication in play here which is throwing off the JMS
component.

I would try to create a simple (non-JNDI) based connection factory object
first and get that working, then try other ways. The error is being thrown
from Spring's JMS Template and it is not being able to create the required
connection factory object.

Cheers,

Ashwin...



-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-ActiveMQ-to-Weblogic-route-tp4578300p4581082.html
Sent from the Camel - Users mailing list archive at Nabble.com.