You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Martin de Reuver <ac...@dereuver.com> on 2015/12/24 15:12:16 UTC

User property in brokerURL

Hi,

in the camel-context i want to use a property value instead of localhost to
configure the activemq brokerURL.

See below my current camel-context.xml within a NetBeans maven project.

<?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:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
       http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <propertyPlaceholder id="properties"
location="file:${user.home}\etc\open311.properties"/>
        <package>nl.mdr.camel.testcameltocdfroute_01</package>
    </camelContext>

    <bean id="activemq" 
          class="org.apache.activemq.camel.component.ActiveMQComponent">

        <property name="brokerURL"
value="tcp://{{open311.amq.host}}:61616"/>
    </bean>
</beans>

The content of my "open311.properties" file is:
open311.amq.host=localhost
open311.amq.port=61616

When using it this way, i receive the following excpetion message in
NetBeans when running:
Exception in thread "main" org.apache.camel.RuntimeCamelException:
java.lang.IllegalArgumentException: Invalid broker URI:
tcp://${open311.amq.host}:61616
	at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1344)
	at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:120)
	at
org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:301)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
	at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
	at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
	at
org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:186)
	at org.apache.camel.spring.Main.doStart(Main.java:140)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:148)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:343)
	at org.apache.camel.spring.Main.main(Main.java:73)
	at
nl.mdr.camel.testcameltocdfroute_01.TestCamelToCDFRoute_01.main(TestCamelToCDFRoute_01.java:42)
Caused by: java.lang.IllegalArgumentException: Invalid broker URI:
tcp://${open311.amq.host}:61616
	at
org.apache.activemq.ActiveMQConnectionFactory.createURI(ActiveMQConnectionFactory.java:236)
	at
org.apache.activemq.ActiveMQConnectionFactory.setBrokerURL(ActiveMQConnectionFactory.java:436)
	at
org.apache.activemq.camel.component.ActiveMQConfiguration.createConnectionFactory(ActiveMQConfiguration.java:144)
	at
org.apache.camel.component.jms.JmsConfiguration.getConnectionFactory(JmsConfiguration.java:471)
	at
org.apache.camel.component.jms.JmsConfiguration.createListenerConnectionFactory(JmsConfiguration.java:1117)
	at
org.apache.camel.component.jms.JmsConfiguration.getListenerConnectionFactory(JmsConfiguration.java:490)
	at
org.apache.camel.component.jms.JmsConfiguration.configureMessageListenerContainer(JmsConfiguration.java:944)
	at
org.apache.camel.component.jms.JmsConfiguration.createMessageListenerContainer(JmsConfiguration.java:434)
	at
org.apache.camel.component.jms.JmsEndpoint.createMessageListenerContainer(JmsEndpoint.java:165)
	at
org.apache.camel.component.jms.JmsEndpoint.createConsumer(JmsEndpoint.java:160)
	at
org.apache.camel.component.jms.JmsEndpoint.createConsumer(JmsEndpoint.java:70)
	at
org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:64)
	at
org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:80)
	at org.apache.camel.impl.RouteService.warmUp(RouteService.java:133)
	at
org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2109)
	at
org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2039)
	at
org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1827)
	at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1699)
	at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1544)
	at
org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:179)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1512)
	at
org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:228)
	at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:118)
	... 14 more
Caused by: java.net.URISyntaxException: Illegal character in authority at
index 6: tcp://${open311.amq.host}:61616
	at java.net.URI$Parser.fail(URI.java:2829)
	at java.net.URI$Parser.parseAuthority(URI.java:3167)
	at java.net.URI$Parser.parseHierarchical(URI.java:3078)
	at java.net.URI$Parser.parse(URI.java:3034)
	at java.net.URI.<init>(URI.java:595)
	at
org.apache.activemq.ActiveMQConnectionFactory.createURI(ActiveMQConnectionFactory.java:234)
	... 37 more

Even when using "tcp://${open311.amq.host}:61616" instead of
"tcp://{{open311.amq.host}}:61616" does not solve the problem.

Even loading the properties file using a bean instead of the camel-context
propertyPlaceholder does not solve the problem.

Anyone an idea how to solve this exception?

Thanks.

Martin.



--
View this message in context: http://activemq.2283324.n4.nabble.com/User-property-in-brokerURL-tp4705435.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.