Question

I want to convert this example to java (i.e. do not use the spring DSL). I can stand up the objects, but am confused about how to reference the JmsComponent bean in the route uri (line 34 of linked example).

Java Example:

    // Stand up JndiTemplate
    Properties env = new Properties();
    env.setValue("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
    env.setValue("java.naming.provider.url","jnp://localhost:1099");
    env.setValue("java.naming.factory.url.pkgs","org.jnp.interfaces:org.jboss.naming");
    JndiTemplate template = new JndiTemplate;
    template.setEnvironment(env);

    // Stand up JndiObjectFactoryBean
    JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
    factory.setJndiTemplate(template);
    factory.setJndiName("ConnectionFactory");

    // Stand up JmsComponent
    JmsComponent component = new JmsComponent();
    component.setSonnectionFactory(factory);

    // Stand up camel context and route
    final CamelContext camelContext = new DefaultCamelContext();
    camelContext.addRoutes(new RouteBuilder() {
        public void configure() {
            from("WHAT_GOES_HERE:topic:myTopic").to("direct:a")
        }
    });
    camelContext.setTracing(true);
    camelContext.start();

Question: How do i reference my JmsComponent within the from URI? and/or Is there a better way to do this using Java/Apache Camel?

Was it helpful?

Solution

Add this:

camelContext.addComponent("test-jms",component);

And Replace:

public void configure() {
    from("WHAT_GOES_HERE:topic:myTopic").to("direct:a")
}

With:

public void configure() {
    from("test-jms:topic:myTopic").to("direct:a")
}

more info here: http://fusesource.com/docs/archives/router/1.6/deploy_guide/FMRDS.ACCC.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top