I want to have centralized shared properties (shared across camel contexts)
to define things, particularly ActiveMQ endpoints. Furthermore, I want to
avoid using /etc/custom.properties, unless I'm unaware of a refresh
mechanism that doesn't require restarting karaf and therefore all bundles. A
point of consideration here is that if I were to use this for endpoints, I
would have to restart the bundles producing to and consuming from them in
order to get changed property values. This is true. It still seems more
concise than bouncing the whole VM and all bundles to get the new
properties.

Here's what I know I can do as a solution:
I am able to reference a "java.util.Properties" service in one bundle when I
inject it as a property on a bean such as a class that extends RouteBuilder
in another bundle. This is perfectly viable, just not as elegant as I'd
like.

Here's what I think I should be able to do as a solution:
It appears I should be able to reference the service since it represents a
java.util.Properties object through the property placeholder thereby using
only the replacement capabilities in Camel, such as {{event.endpoint}}
whether in Blueprint DSL or in Java. Ultimately I'm trying not to have to
have some Java code to access shared properties. 

I've actually tried a few permutations of the following xml snippets but
this demonstrates exactly what I'm trying to accomplish. After these
snippets I've posted some of the stack trace from karaf. I'm a little
confused why it's throwing a FileNotFoundException. I guess a subordinate
question is, does there need to be a concrete properties file somewhere or
do I possibly lack the setup of a proper Registry (see
http://camel.apache.org/using-propertyplaceholder.html under Using
Properties from the Registry section). If am missing something on the
registry maybe I need to do a little more reading on that subject.

I'm using Karaf 2.2.5.fuse-70-097 and Camel 2.9.0.fuse-70-097 in FuseESB
7.0.2.fuse-097

Here is the blueprint in the service bundle:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
          
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
           xmlns:blueprint="http://www.osgi.org/xmlns/blueprint/v1.0.0";>

    <service id="vmProperties" interface="java.util.Properties">
        <bean class="java.util.Properties">
            <argument>
                <props>
                    <prop
key="event.endpoint">activemq:myapp.event.queue</prop>
                    <prop
key="command.endpoint">activemq:myapp.command.queue</prop>
                </props>
            </argument>
        </bean>
    </service>
</blueprint>

Here is the blueprint for the camel route bundle:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
          
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0";
          
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
           xmlns:amq="http://activemq.apache.org/schema/core";
           xmlns:cml="http://camel.apache.org/schema/blueprint";
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint/camel-blueprint-2.9.0.xsd";>

    <cml:camelContext id="test-camel-context" >
        <cml:propertyPlaceholder location="ref:vmProperties" />
        <cml:route>
            <cml:from uri="{{event.endpoint}}" />
            <cml:setBody>
                <cml:constant>Hello Universe</cml:constant>
            </cml:setBody>
            <cml:log message="########## Sending Test Message" />
            <cml:to uri="{{command.endpoint}}" />
        </cml:route>
        
        <cml:route>
            <cml:from uri="{{command.endpoint}}" />
            <cml:log message="########## Test Message Received" />
        </cml:route>      
    </cml:camelContext>
</blueprint>


Karaf log includes the following:

2013-02-05 10:40:12,455 | ERROR | l-0.0.0-thread-1 | BlueprintContainerImpl     
     
| 10 - org.apache.aries.blueprint - 0.3.1.fuse-70-097 | Unable to start
blueprint container for bundle a-route.xml
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
intialize bean test-camel-context
....
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
route route23: Route[[From[{{event.endpoint}}]] -> [SetBody[consta...
because of Failed to resolve endpoint: {{event.endpoint}} due to: Properties
vmProperties not found in registry
...
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint: {{event.endpoint}} due to: Properties vmProperties not
found in registry
...
Caused by: java.io.FileNotFoundException: Properties vmProperties not found
in registry




--
View this message in context: 
http://camel.465427.n5.nabble.com/Reference-OSGI-Blueprint-java-util-Properties-service-in-Blueprint-Camel-property-placeholder-tp5726985.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to