Hi,
I'm new to Jboss Cache and I'm trying to use Jboss Cache 1.4.0SP11
"Cayenne" to cache some of my entities.
I'm using for my application jboss-4.0.5-GA version of the server, in configuration
all. The application is using ejb3 entities and I need to reduce the amounts of DB calls
to some tables by using the jboss level 2 cache.
I already install EJB3 RC9 Patch 1 for my server configuration, and configured the
ejb3-entity-cache-service.xml as following:
<?xml version="1.0" encoding="UTF-8"?>
<!-- ==================================================================== -->
<!-- Defines TreeCache configuration -->
<!-- ==================================================================== -->
jboss:service=Naming
jboss:service=TransactionManager
<!--depends>jboss.j2ee:ear=syncml-connector.ear,jar=syncml.jar,name=SyncMLConnectorDataService,service=EJB3</depends-->
<!-- uncomment next three statements if using JGroups multiplexer,
requires JGroups 2.3 or later, JBossCache 1.4 or later -->
<!--
jgroups.mux:name=Multiplexer
jgroups.mux:name=Multiplexer
fc-fast-minimalthreads
-->
<!-- Configure the TransactionManager -->
org.jboss.cache.JBossTransactionManagerLookup
<!--
Node locking level : SERIALIZABLE
REPEATABLE_READ (default)
READ_COMMITTED
READ_UNCOMMITTED
NONE
-->
REPEATABLE_READ
<!-- Valid modes are LOCAL
REPL_ASYNC
REPL_SYNC
-->
LOCAL
<!-- Name of cluster. Needs to be the same for all clusters, in order
to find each other -->
EJB3-entity-cache
<!-- Must be true if any entity deployment uses a scoped classloader -->
true
<!-- Must match the value of "UseRegionBasedMarshalling" -->
true
OPTIMISTIC
<!-- UDP: if you have a multihomed machine,
set the bind_addr attribute to the appropriate NIC IP address
-->
<!-- UDP: On Windows machines, because of the media sense feature
being broken with multicast (even after disabling media sense)
set the loopback attribute to true
-->
<UDP mcast_addr="${jboss.partition.udpGroup:228.1.2.3}"
mcast_port="43333" ip_ttl="${jgroups.mcast.ip_ttl:2}"
ip_mcast="true"
mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
ucast_send_buf_size="150000"
ucast_recv_buf_size="80000" loopback="false" />
<PING timeout="2000" num_initial_members="3"
up_thread="false" down_thread="false" />
<MERGE2 min_interval="10000" max_interval="20000" />
<FD_SOCK down_thread="false" up_thread="false"/>
<FD shun="true" up_thread="false"
down_thread="false"
timeout="20000" max_tries="5"/>
<VERIFY_SUSPECT timeout="1500" up_thread="false"
down_thread="false" />
<pbcast.NAKACK gc_lag="50" max_xmit_size="8192"
retransmit_timeout="600,1200,2400,4800" up_thread="false"
down_thread="false" />
<UNICAST timeout="600,1200,2400" window_size="100"
min_threshold="10" down_thread="false" />
<pbcast.STABLE desired_avg_gossip="20000" up_thread="false"
down_thread="false" />
<FRAG frag_size="8192" down_thread="false"
up_thread="false" />
<pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
shun="true" print_local_addr="true" />
<pbcast.STATE_TRANSFER up_thread="false"
down_thread="false" />
<!-- The max amount of time (in milliseconds) we wait until the
initial state (ie. the contents of the cache) are retrieved from
existing members in a clustered environment
-->
5000
<!-- Number of milliseconds to wait until all responses for a
synchronous call have been received.
-->
10000
<!-- Max number of milliseconds to wait for a lock acquisition -->
15000
<!-- Name of the eviction policy class. -->
org.jboss.cache.eviction.LRUPolicy
<!-- Specific eviction policy configurations. This is LRU -->
5 -->
<!-- Cache wide default -->
10000
86400
The entities needed to cache were annotated this way:
@Entity(name = "DataStoresConnEntity")
@Table(name = "DATASTORES", uniqueConstraints = {})
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@NamedQueries(...)
public class DataStoresConnEntity implements Serializable
{
....
@OneToMany(mappedBy = "dataStoresEntity", fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public Collection getPendingDataStoresEntities()
{
return pendingDataStoresEntities;
}
....
}
and
@Entity(name = "PendingDataStoresConnEntity")
@Table(name = "PENDINGDATASTORES")
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@NamedQueries(...)
public class PendingDataStoresConnEntity implements Serializable
{
...
@ManyToOne(targetEntity = DataStoresConnEntity.class)
@JoinColumn(name = "DATASTOREID", referencedColumnName =
"DATASTOREID")
public DataStoresConnEntity getDataStoresEntity()
{
return dataStoresEntity;
}
...
}
We decided that the named queries doesn't need to be cached only the ejb3 entities.
The problem is that after some processing, when the processing stops, the entities are
evicted from the cache very fast , after few seconds(~10s). I tried also to set up
wakeUpIntervalSeconds to a large number and also tried a setup for
"maxAgeSeconds" to 0.
Even if I remove the evictionPolicy the behavior is still the same.
Does anybody have an idea why this strange behavior is happening?
Since the new year is coming soon I wish you a Happy New Year!
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4199028#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...