You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "skydjol (JIRA)" <ji...@apache.org> on 2010/12/29 15:33:45 UTC
[jira] Created: (CAMEL-3473) register several cacheEnpoint with
different name
register several cacheEnpoint with different name
-------------------------------------------------
Key: CAMEL-3473
URL: https://issues.apache.org/jira/browse/CAMEL-3473
Project: Camel
Issue Type: Bug
Affects Versions: 2.5.0
Reporter: skydjol
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.
[jira] Resolved: (CAMEL-3473) register several cacheEnpoint with
different name
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-3473?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-3473.
--------------------------------
Resolution: Fixed
Thanks Tracy for the patch.
trunk: 1055051.
> 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
> Assignee: Tracy Snell
> Priority: Minor
> Fix For: 2.6.0
>
> Attachments: patchfile.txt
>
>
> 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.
[jira] Commented: (CAMEL-3473) register several cacheEnpoint with
different name
Posted by "Tracy Snell (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Assigned: (CAMEL-3473) register several cacheEnpoint with
different name
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-3473?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen reassigned CAMEL-3473:
----------------------------------
Assignee: Tracy Snell
> 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
> Assignee: Tracy Snell
> 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.
[jira] Commented: (CAMEL-3473) register several cacheEnpoint with
different name
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-3473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976200#action_12976200 ]
Claus Ibsen commented on CAMEL-3473:
------------------------------------
Can you elaborate a bit more whats the problem?
Can you attach a test case which demonstrates the issue?
And we love contributions, so you are welcome to work on a patch.
http://camel.apache.org/contributing.html
> register several cacheEnpoint with different name
> -------------------------------------------------
>
> Key: CAMEL-3473
> URL: https://issues.apache.org/jira/browse/CAMEL-3473
> Project: Camel
> Issue Type: Bug
> Affects Versions: 2.5.0
> Reporter: skydjol
>
> 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.
[jira] Updated: (CAMEL-3473) register several cacheEnpoint with
different name
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-3473?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen updated CAMEL-3473:
-------------------------------
Priority: Minor (was: Major)
Fix Version/s: 2.6.0
> register several cacheEnpoint with different name
> -------------------------------------------------
>
> Key: CAMEL-3473
> URL: https://issues.apache.org/jira/browse/CAMEL-3473
> Project: Camel
> Issue Type: Bug
> 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.
[jira] Updated: (CAMEL-3473) register several cacheEnpoint with
different name
Posted by "Tracy Snell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-3473?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tracy Snell updated CAMEL-3473:
-------------------------------
Attachment: patchfile.txt
Changed to defensively copy the config to each endpoint on creation. Added a simple test to confirm.
> 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
> Assignee: Tracy Snell
> Priority: Minor
> Fix For: 2.6.0
>
> Attachments: patchfile.txt
>
>
> 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.
[jira] Commented: (CAMEL-3473) register several cacheEnpoint with
different name
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-3473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12977243#action_12977243 ]
Claus Ibsen commented on CAMEL-3473:
------------------------------------
Ah yeah Tracy that would be the problem. See the camel-mail component where the Configuration instance is defensively copied when creating an endpoint.
> 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.
[jira] Updated: (CAMEL-3473) register several cacheEnpoint with
different name
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-3473?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen updated CAMEL-3473:
-------------------------------
Component/s: camel-cache
> 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.