Proxy authentication with Camel using ProducerTemplate

匆匆过客 提交于 2019-12-02 09:15:32

If I'm right, the problem is more like you cannot reach the properties in SMX. ServiceMix supports SpringDM and I'd suggest to use that to request for the properties from Configuration Admin.

0) Assuming you're using Spring, your main-appContext xml must be placed under resources/META-INF/spring/, SMX will look for it there to initialize your app.

1) Add a different property file to ServiceMix/etc (do not use system.properties). It must be named as *.cfg, i.e.: my.properties.cfg

1.5) Ensure the config is loaded. In SMX, enter:

config:update
config:list | grep my.prop.name

2) You'll need this file to be resolved by Spring DM. Add appcontext xml content like the following (ensure you have the namespaces).

<?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"
    xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/osgi-compendium 
       http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">

    <osgix:cm-properties id="myProperties" persistent-id="my.properties" /> <!--without the extension-->
    <context:property-placeholder ignore-unresolvable="true" properties-ref="myProperties" />
</beans>

3.) import this appcontext as well and use the properties through ${my.prop} placeholders.

Hope this helps!

Try this code:

HTTPConduit conduit = (HTTPConduit)outMessage.getExchange().getConduit(outMessage);
HTTPClientPolicy policy = conduit.getClient();
policy.setProxyServer(PROXY_IP);
policy.setProxyServerPort(PROXY_PORT);
conduit.setClient(policy);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!