Hi Hendy,
I just created a JIRA for this issue and committed a fix for it.
Now you can use proxy out side of the camelContext.
If there is only one camelContext in the spring applicationContext , you
don't need to specify the camelContextId attribute, otherwise you need
to specify it.
Please check it out the latest Camel 2.2-SNAPSHOT to try on this fix.
Willem
Willem Jiang wrote:
Hendy Irawan wrote:
I'd love to have ability to put camel:proxy outside and set camelContext
myself.
For simple purposes, I can configure Spring to autowire camelContext.
I just checked the code of CamelNamespaceHandler.java[1] if you just
want to define the <camel:proxy> out side of camelContext, we need to
implement mapping the camelContextId into the camelContext instance
ourselves, as there could be more than one camelContext in the spring
application context.
If you are OK for adding camelContextId attribute in the <camel:proxy>
element, I will head to implement this feature shortly.
[1]https://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
willem.jiang wrote:
Hi,
Current <camel:proxy> is not support to be defined out side of the
camelContext. as we set the implicit camelContext into the
CamelProxyFactoryBean when parsing the proxy element.
If you want to use it outside the camelContext , you need to specify
the camelContext property yourself. To avoid the user forget to
specify the camelContext, we just let the proxy parser visible inside
of the camelContext.
Willem
Hendy Irawan wrote:
The following works:
<camelContext xmlns="http://camel.apache.org/schema/spring">
<packageScan>
<package>com.soluvas.samples.eventfx.camel</package>
</packageScan>
<camel:proxy id="sensorEventListener"
serviceUrl="seda:Sensor.SensorEvent"
serviceInterface="com.soluvas.samples.eventfx.camel.Listener" />
</camelContext>
but this doesn't work:
<bean class="com.soluvas.samples.eventfx.camel.Sensor">
<property name="sensorListener">
<camel:proxy serviceUrl="seda:Sensor.SensorEvent"
serviceInterface="com.soluvas.samples.eventfx.camel.Listener" />
</property>
</bean>
and I have to do this:
<bean class="com.soluvas.samples.eventfx.camel.Sensor">
<property name="sensorListener">
<bean
class="org.apache.camel.spring.remoting.CamelProxyFactoryBean">
<property name="serviceUrl"
value="seda:Sensor.SensorEvent"/>
<property name="serviceInterface"
value="com.soluvas.samples.eventfx.camel.Listener"/>
</bean>
</property>
</bean>
It's too bad, because `camel:proxy` is very useful and makes Spring
Remoting
- Camel concise and readable.
Is it intentional or is there plans to make camel:proxy works
everywhere
(even nested inside 'property')?