[
https://issues.apache.org/jira/browse/CAMEL-9570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15178052#comment-15178052
]
Quinn Stevenson commented on CAMEL-9570:
----------------------------------------
I've tried to determine the difference between the two, and the call path for
the service looks to be identical as near as I can tell.
I'm using a route where I call the service via to( "bean:beadId" ). The
RouteBuilder has a setter for the bean reference, but it's never used. When
the service reference is injected into the RouteBuilder, the route will never
pickup a new service. In addition, it keeps calling the old service even
though it has been unregistered.
Here's my RouteBuilder
public class ServiceConsumerBuilder extends RouteBuilder{
Logger log = LoggerFactory.getLogger(this.getClass());
String beanId = "osgi-service";
String timerName = "default-timer";
Object beanInstance;
public ServiceConsumerBuilder() {
}
@Override
public void configure() throws Exception {
fromF( "timer://%s?period=%d&fixedRate=%b", timerName, 5000, true)
.routeId( "java-route")
.setBody().constant( "Dummy Value")
.toF( "bean://%s?cache=%b&method=%s", beanId, false, "execute")
.to( "mock://result")
;
}
public String getTimerName() {
return timerName;
}
public void setTimerName(String timerName) {
this.timerName = timerName;
}
public String getBeanId() {
return beanId;
}
public void setBeanId(String beanId) {
this.beanId = beanId;
}
public Object getBeanInstance() {
return beanInstance;
}
public void setBeanInstance(Object beanInstance) {
Exception ex = new Exception();
ex.fillInStackTrace();
log.info( "Setting beanInstance", ex );
this.beanInstance = beanInstance;
}
public static void main( String[] args ) {
System.out.println( "Hello");
}
}
Here's a Blueprint that works
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:camel="http://camel.apache.org/schema/blueprint"
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
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<cm:property-placeholder persistent-id="blueprint-test"
update-strategy="reload" >
<cm:default-properties>
<cm:property name="timer-name" value="blueprint-consumer" />
</cm:default-properties>
</cm:property-placeholder>
<reference id="osgi-service"
interface="com.pronoia.osgi.service.MyServiceInterface"
filter="implementation=bp-external"/>
<bean id="java-route"
class="com.pronoia.camel.builder.ServiceConsumerBuilder" >
<property name="beanId" value="osgi-service" />
<property name="timerName" value="java-${timer-name}" />
</bean>
<camelContext id="blueprint-context"
xmlns="http://camel.apache.org/schema/blueprint">
<routeBuilder ref="java-route" />
</camelContext>
</blueprint>
And here's a blueprint that doesn't work
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:camel="http://camel.apache.org/schema/blueprint"
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
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<cm:property-placeholder persistent-id="blueprint-test"
update-strategy="reload" >
<cm:default-properties>
<cm:property name="timer-name" value="blueprint-consumer" />
</cm:default-properties>
</cm:property-placeholder>
<reference id="osgi-service"
interface="com.pronoia.osgi.service.MyServiceInterface"
filter="implementation=bp-external"/>
<bean id="java-route"
class="com.pronoia.camel.builder.ServiceConsumerBuilder" >
<property name="beanId" value="osgi-service" />
<property name="beanInstance" ref="osgi-service" />
<property name="timerName" value="java-${timer-name}" />
</bean>
<camelContext id="blueprint-context"
xmlns="http://camel.apache.org/schema/blueprint">
<routeBuilder ref="java-route" />
</camelContext>
</blueprint>
> Blueprint Proxies are not used when injected into Java RouteBuilders
> --------------------------------------------------------------------
>
> Key: CAMEL-9570
> URL: https://issues.apache.org/jira/browse/CAMEL-9570
> Project: Camel
> Issue Type: Bug
> Components: camel-blueprint, camel-core
> Affects Versions: 2.16.2
> Reporter: Quinn Stevenson
> Assignee: Christian Schneider
>
> Basic Conditions:
> - Java interface used for OSGi Services
> - Implementation of the Java interface registered as a OSGi service. Note
> that the package containing implementation is NOT exported
> - A Java RouteBuilder that uses the Java interface via bean(...) DSL calls,
> with a setter for the bean implementing the interface
> - Wire everything together with Blueprint - create a <reference ...> for the
> service, a <bean ...> for the RouteBuilder and inject the service reference,
> and use the RouteBuilder in a CamelContext.
> After all this is deployed, stop the bundle implementing the service. A
> ServiceUnavailableException should be thrown after a timeout, but the object
> that was injected into the RouteBuilder process the request - so the
> Blueprint Proxy is not used.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)