You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Sebastián Laborde (JIRA)" <ji...@apache.org> on 2016/08/09 18:47:20 UTC

[jira] [Updated] (CAMEL-10230) Items in the cache expires even though eternal is set to true.

     [ https://issues.apache.org/jira/browse/CAMEL-10230?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebastián Laborde updated CAMEL-10230:
--------------------------------------
    Description: 
Items in the cache expires even though eternal is set to true. When a new element is added to the cache, its properties are set to its default values.

Only seems to work as expected if I put the cache properties into the route itself everytime I add an item into the cache (see below, bolded text). 

CacheRouteBuilder:

package uy.com.antel.pi.osgi.cache;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cache.CacheConstants;

public class CacheRouteBuilder extends RouteBuilder {

	private CacheAggregationStrategy CAS = new CacheAggregationStrategy();
	
	@Override
	public void configure() throws Exception {
		// TODO Auto-generated method stub
		
		// Set up Cache
		from("cache://MyApplicationCache?eternal=true&diskPersistent=true")
			.to("mock:endpoint");
		
		// CXFRS Entry Point
		from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer")
			.log("GET Request Received...")
			.choice()
				.when(header("operationName").isEqualTo("addEntry"))
					.log("In add entry choice")
					.log("${headers}")
					.to("bean:restImplBean?method=addEntry")
					.to("cache://MyApplicationCache*?eternal=true&diskPersistent=true*")
					.to("bean:restImplBean?method=addedEntry")
				.when(header("operationName").isEqualTo("getEntry"))
					.log("In get entry choice")
					.to("bean:restImplBean?method=getEntry")
					.to("cache://MyApplicationCache")
					.log("${headers}")
					.choice()
						.when(header(CacheConstants.CACHE_ELEMENT_WAS_FOUND).isNull())
				        .to("bean:restImplBean?method=notFound")
				        .otherwise()
				        .to("bean:restImplBean?method=gotEntry")
				    .end()
			.end();
		
		}


  was:
Items in the cache expires even though eternal is set to true. When a new element is added to the cache, its properties are set to its default values.

I also put the cache properties into the route itself (see below, bolded text) and with 

CacheRouteBuilder:

package uy.com.antel.pi.osgi.cache;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cache.CacheConstants;

public class CacheRouteBuilder extends RouteBuilder {

	private CacheAggregationStrategy CAS = new CacheAggregationStrategy();
	
	@Override
	public void configure() throws Exception {
		// TODO Auto-generated method stub
		
		// Set up Cache
		from("cache://MyApplicationCache?eternal=true&diskPersistent=true")
			.to("mock:endpoint");
		
		// CXFRS Entry Point
		from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer")
			.log("GET Request Received...")
			.choice()
				.when(header("operationName").isEqualTo("addEntry"))
					.log("In add entry choice")
					.log("${headers}")
					.to("bean:restImplBean?method=addEntry")
					.to("cache://MyApplicationCache*?eternal=true&diskPersistent=true*")
					.to("bean:restImplBean?method=addedEntry")
				.when(header("operationName").isEqualTo("getEntry"))
					.log("In get entry choice")
					.to("bean:restImplBean?method=getEntry")
					.to("cache://MyApplicationCache")
					.log("${headers}")
					.choice()
						.when(header(CacheConstants.CACHE_ELEMENT_WAS_FOUND).isNull())
				        .to("bean:restImplBean?method=notFound")
				        .otherwise()
				        .to("bean:restImplBean?method=gotEntry")
				    .end()
			.end();
		
		}



> Items in the cache expires even though eternal is set to true.
> --------------------------------------------------------------
>
>                 Key: CAMEL-10230
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10230
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-cache
>    Affects Versions: 2.16.2
>         Environment: Camel 2.16.3 - ServiceMix 7.0.0.M2
>            Reporter: Sebastián Laborde
>
> Items in the cache expires even though eternal is set to true. When a new element is added to the cache, its properties are set to its default values.
> Only seems to work as expected if I put the cache properties into the route itself everytime I add an item into the cache (see below, bolded text). 
> CacheRouteBuilder:
> package uy.com.antel.pi.osgi.cache;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.cache.CacheConstants;
> public class CacheRouteBuilder extends RouteBuilder {
> 	private CacheAggregationStrategy CAS = new CacheAggregationStrategy();
> 	
> 	@Override
> 	public void configure() throws Exception {
> 		// TODO Auto-generated method stub
> 		
> 		// Set up Cache
> 		from("cache://MyApplicationCache?eternal=true&diskPersistent=true")
> 			.to("mock:endpoint");
> 		
> 		// CXFRS Entry Point
> 		from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer")
> 			.log("GET Request Received...")
> 			.choice()
> 				.when(header("operationName").isEqualTo("addEntry"))
> 					.log("In add entry choice")
> 					.log("${headers}")
> 					.to("bean:restImplBean?method=addEntry")
> 					.to("cache://MyApplicationCache*?eternal=true&diskPersistent=true*")
> 					.to("bean:restImplBean?method=addedEntry")
> 				.when(header("operationName").isEqualTo("getEntry"))
> 					.log("In get entry choice")
> 					.to("bean:restImplBean?method=getEntry")
> 					.to("cache://MyApplicationCache")
> 					.log("${headers}")
> 					.choice()
> 						.when(header(CacheConstants.CACHE_ELEMENT_WAS_FOUND).isNull())
> 				        .to("bean:restImplBean?method=notFound")
> 				        .otherwise()
> 				        .to("bean:restImplBean?method=gotEntry")
> 				    .end()
> 			.end();
> 		
> 		}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)