[ https://issues.apache.org/jira/browse/CAMEL-3473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12977050#action_12977050 ]
Tracy Snell commented on CAMEL-3473: ------------------------------------ I think I follow his issue, I hit it in camel-aws. If the configuration is per component that assumes that all endpoints share the same configuration. In camel-aws' case this meant that you couldn't have a route that consumed from one aws account and produced to another (among other things). In this case the URI points to the URI of the last endpoint created, for all endpoints. His change would move the config to the endpoint and solve the problem. I'll be glad to make the code change and test if no one else is. > register several cacheEnpoint with different name > ------------------------------------------------- > > Key: CAMEL-3473 > URL: https://issues.apache.org/jira/browse/CAMEL-3473 > Project: Camel > Issue Type: Bug > Components: camel-cache > Affects Versions: 2.5.0 > Reporter: skydjol > Priority: Minor > Fix For: 2.6.0 > > > When you declare in camel context > <camel:endpoint id="cache1" uri="cache:cache1" /> > <camel:endpoint id="cache2" uri="cache:cache2" /> > <camel:endpoint id="cache3" uri="cache:cache3" /> > CamelCacheProducer produce systematically in same cache because in > CacheComponent, CacheConfiguration is modified by method createEndpoint > {code:title=CamelCacheProducer.java|borderStyle=solid} > public void process(Exchange exchange) throws Exception { > if (LOG.isTraceEnabled()) { > LOG.trace("Cache Name: " + config.getCacheName()); > } > if (cacheManager.cacheExists(config.getCacheName())) { > if (LOG.isTraceEnabled()) { > LOG.trace("Found an existing cache: " + > config.getCacheName()); > LOG.trace("Cache " + config.getCacheName() + " currently > contains " > + > cacheManager.getCache(config.getCacheName()).getSize() + " elements"); > } > cache = cacheManager.getCache(config.getCacheName()); > } else { > cache = new Cache(config.getCacheName(), > config.getMaxElementsInMemory(), > config.getMemoryStoreEvictionPolicy(), > config.isOverflowToDisk(), > config.getDiskStorePath(), > config.isEternal(), > config.getTimeToLiveSeconds(), > config.getTimeToIdleSeconds(), > config.isDiskPersistent(), > config.getDiskExpiryThreadIntervalSeconds(), > null); > cacheManager.addCache(cache); > if (LOG.isDebugEnabled()) { > LOG.debug("Added a new cache: " + cache.getName()); > } > } > String key = exchange.getIn().getHeader(CacheConstants.CACHE_KEY, > String.class); > String operation = > exchange.getIn().getHeader(CacheConstants.CACHE_OPERATION, String.class); > if (operation == null) { > throw new CacheException("Operation not specified in the message > header [" + CacheConstants.CACHE_KEY + "]"); > } > if ((key == null) && > (!operation.equalsIgnoreCase(CacheConstants.CACHE_OPERATION_DELETEALL))) { > throw new CacheException("Cache Key is not specified in message > header header or endpoint URL."); > } > performCacheOperation(exchange, operation, key); > } > {code} > {code:title=CacheComponent.java|borderStyle=solid} > public class CacheComponent extends DefaultComponent { > private CacheConfiguration config; > private CacheManagerFactory cacheManagerFactory = new > CacheManagerFactory(); > > public CacheComponent() { > config = new CacheConfiguration(); > } > public CacheComponent(CamelContext context) { > super(context); > config = new CacheConfiguration(); > } > @Override > @SuppressWarnings("unchecked") > protected Endpoint createEndpoint(String uri, String remaining, Map > parameters) throws Exception { > config.parseURI(new URI(uri)); > > CacheEndpoint cacheEndpoint = new CacheEndpoint(uri, this, config, > cacheManagerFactory); > setProperties(cacheEndpoint.getConfig(), parameters); > return cacheEndpoint; > } > public CacheManagerFactory getCacheManagerFactory() { > return cacheManagerFactory; > } > public void setCacheManagerFactory(CacheManagerFactory > cacheManagerFactory) { > this.cacheManagerFactory = cacheManagerFactory; > } > @Override > protected void doStart() throws Exception { > super.doStart(); > ServiceHelper.startService(cacheManagerFactory); > } > @Override > protected void doStop() throws Exception { > ServiceHelper.stopService(cacheManagerFactory); > super.doStop(); > } > } > {code} > The resolution could be in CacheComponent > {code:title=CacheComponent.java|borderStyle=solid} > @Override > @SuppressWarnings("unchecked") > protected Endpoint createEndpoint(String uri, String remaining, Map > parameters) throws Exception { > CacheConfiguration config = new CacheConfiguration(); > config.parseURI(new URI(uri)); > > CacheEndpoint cacheEndpoint = new CacheEndpoint(uri, this, config, > cacheManagerFactory); > setProperties(cacheEndpoint.getConfig(), parameters); > return cacheEndpoint; > } > {code} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.