camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlidholm <johnny.lidh...@gmail.com>
Subject Camel XML DSL route custom bean for testing Weblogic Availiability helper hangs on startup
Date Mon, 11 Jul 2016 14:36:14 GMT
Hi,

I'm trying to use a custom POJO configured as a bean in a Camel XML DSL
route.
This POJO in its constructor tries to call two static methods in the Oracle
Weblogic Availability Helper class. But this call never returns, whether I'm
stepping in debug or just running it.

The calls to the helper class run fine when running locally from a plain
Main method in a local class in Eclipse (not as a part of a Camel route).

The code is the sample code from the Oracle documentation
(https://docs.oracle.com/cd/E17904_01/web.1111/e13727/dahelper.htm#JMSPG935):
And it hangs on the call "JMSDestinationAvailabilityHelper.getInstance()".
When I instead sent the JMSDestinationAvailabilityHelper in as a bean-ref to
the POJO bean, I got passed that call but got stuck on the second
"dah.register(...)" never returning.

--- === Oracle Sample code BEGIN === ---
/import java.util.Hashtable;
import javax.naming.Context;
import weblogic.jms.extensions.JMSDestinationAvailabilityHelper;

Hashtable contextProps = new Hashtable();
contextProps.put(javax.naming.Context.PROVIDER_URL, myURL);
contextProps.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
JMSDestinationAvailabilityHelper dah =
JMSDestinationAvailabilityHelper.getInstance();

RegistrationHandler rh = dah.register(
   contextProperties,
   destinationJNDIName,
   myDestinationAvailableListener
)/
--- === Oracle Sample code END === ---

Not sure I'm making my problem clear, but would appreciate any hints if
anyone gets what might be going on.
Is there some other way I need to wire my bean? Or define the POJO?

Parts of my camel-context.xml:
    <bean id="jndiTemplate" 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">${weblogicJMS.url}</prop>
           <prop
key="java.naming.security.principal">${weblogicJMS.username}</prop>
           <prop
key="java.naming.security.credentials">${weblogicJMS.password}</prop>
         </props>
       </property>
    </bean>

    <bean id="testClassResolve"
class="weblogic.jms.extensions.JMSDestinationAvailabilityHelper"/>

    <bean id="topicPollH08"
class="camel.engine.jms.JMSTopicPollingProcessor" scope="singleton">
      <constructor-arg index="0" ref="jndiTemplate"/>
      <constructor-arg index="1" value="${weblogicJMS.topic.name}"/>
      <constructor-arg index="2" ref="testClassResolve"/>
    </bean>

The code of the POJO:
package camel.engine.jms;


import java.util.Hashtable;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jndi.JndiTemplate;

import weblogic.jms.extensions.DestinationAvailabilityListener;
import weblogic.jms.extensions.DestinationDetail;
import weblogic.jms.extensions.JMSDestinationAvailabilityHelper;
import weblogic.jms.extensions.RegistrationHandle;



//
// The JMSTopicPollingProcessor polls a given JMS Topic and returns the
first message to the camel Exchange.

public class JMSTopicPoller implements DestinationAvailabilityListener {

  private static final Logger log =
LoggerFactory.getLogger(JMSTopicPoller.class);
  private JndiTemplate jndiTemplate;
  private JMSDestinationAvailabilityHelper dah;
  private RegistrationHandle rh;
  
  private String topicName;

  public JMSTopicPoller(JndiTemplate jndiTemplate, String topicName,
JMSDestinationAvailabilityHelper dah) throws Exception {
    this.jndiTemplate = jndiTemplate;
    this.topicName = topicName;
    this.dah = dah;
    initConnection();
  }
  
  private void initConnection() throws Exception {
    
    Hashtable<String, String> contextProps = new Hashtable<String,
String>();
    for(final String name:
jndiTemplate.getEnvironment().stringPropertyNames()) {
      contextProps.put(name,
jndiTemplate.getEnvironment().getProperty(name));
    }
    
    log.debug("JMSTopicPollingProcessor - trying to register Weblogic
Destination Availability listener");

    rh = dah.register(
       contextProps,
       topicName,
       this
    );
    
    log.debug("JMSTopicPollingProcessor - Registered Weblogic Destination
Avalability listener");
}

  @Override
  public void onDestinationsAvailable(String arg0, List<DestinationDetail>
arg1) {
    log.debug("Destinations available");
  }

  @Override
  public void onDestinationsUnavailable(String arg0, List<DestinationDetail>
arg1) {
    log.debug("Destinations unavailable");
    
  }

  @Override
  public void onFailure(String arg0, Exception arg1) {
    log.debug("Failure!");
  }
}




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-XML-DSL-route-custom-bean-for-testing-Weblogic-Availiability-helper-hangs-on-startup-tp5785015.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message