I’ve looked through many Camel sources (Camel in Action, Camel documentation
for components on the net) but did not manage to solve the following
problem.
I'm trying to deploy a route which uses the camel-cache component, however,
I'm getting the well-known org.apache.camel.ResolveEndpointFailedException:
Failed to resolve endpoint: cache://test due to: No component found with
scheme: cache.
I'm deploying an OSGi bundle containing the route definition to an Equinox
OSGi container. Here is how my route definition looks like:
<camelContext autoStartup="true"
xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="vm://channelName"/>
<setHeader headerName="CamelCacheOperation">
<simple>CamelCacheAdd</simple>
</setHeader>
<setHeader headerName="CamelCacheKey">
<simple>ShindovCache</simple>
</setHeader>
<to uri="cache://test" />
</route>
</camelContext>
As I don't have the Ehcache library (ehcache.jar) that is required by
camel-cache as an OSGi bundle, I have added the library to a directory
called “lib” within the camel-cache bundle and modified its manifest by
adding the following instruction:
Bundle-ClassPath: .,lib/ehcache.jar.
Please note that the camel-cache component bundle gets activated
successfully and exposes the following services:
"Registered Services"
{org.apache.camel.spi.ComponentResolver}={component=[cache],
service.id=961}
{org.apache.camel.spi.TypeConverterLoader}={service.id=962}
To me, it looks like the camel-cache component is working properly as it
exposes the ComponentResolver service with filter component=[cache] (Camel
component auto discovery feature?).
Is it possible that the camel-cache bundle is not operating properly and
because of this I'm getting "No component found with scheme: cache"?
If we can assume that everything is OK with the camel-cache component, then
it must be something wrong in the way I’m using the cache component. Do I
need to configure and add this component explicitly to a camel context, or I
can rely on Camel’s component auto discovery?
I tried to define a bean of type CacheComponent with id="cache2" and used
this id in the uri. As a result, I got the following:
Caused by: java.lang.IllegalArgumentException: Unrecognized Cache protocol:
cache2 for uri: cache2://TestCache1
at
org.apache.camel.component.cache.CacheConfiguration.parseURI(CacheConfiguration.java:62)
When I cerate routes with JMS based endpoints for example, I first define a
bean of type JmsComponent (<bean id=”jmsBean”
class=”org.apache.camel.components.jms.JmsComponent”) and then specify
“jmsBean:topic:topicName” as an uri. Should I use the same approach when
dealing with cache endpoints? If so, this is a bit confusing for me and
rises the following questions:
- If I want to define from/to endpoints with a non-default camel component,
when do I need to explicitly create a bean of the desired component type and
when can I simply type from(“component:name?options”)?
- What’s the point of having camel-jms exposing a
org.apache.camel.spi.ComponentResolver}={component=[jms] service, when I
always need to create a JMS component bean with a connection factory
injected before using “jms:topic:…”?
Thanks in advance for the assistance.
Best regards,
Atanas
--
View this message in context: http://camel.465427.n5.nabble.com/Usage-of-Camel-cache-component-Camel-component-auto-discovery-tp5743113.html
Sent from the Camel - Users mailing list archive at Nabble.com.