3

WE have Website build on Spring-MVC Java platform and using DD4T 2.0.5(Java APIs) and Tridion 2013 Sp1. Tridion Cache Channel service deployed as windows service on CMS server(windows 2013 server). looks like below:

Content Delivery(unix box A)
Website(unix box B)
Tridion cache Channel service(windows box C)

Q#1:what it needs to enable DD4T cache; not sure what exact set of config changes it needs at application end or Tridion end.

Q#2:To ensure the DD4T cache invalidation is done by Tridion Cache Channel service automatically. what configuration it needs. Are both RMI and JMS options open here?

Q#3: If both Tridion Object cache and DD4T cache are enabled then which tridion items will get cached by Tridion Object Cache and which by DD4T cache?

I went through number of stack exchange threads raised on similar question but not able to find the concrete answer.

2

First of all, you will need to setup JMS as your cache invalidation mechanism, as DD4T's caching mechanism does not support listening to RMI. You can read all about that in Quirijn's blog post and the follow-up post.

To enable JMS cache invalidation in a dd4t-2.0 webapp, you need to do the following:

  1. Ensure the following dependencies are present:

    <dependency>
        <groupId>org.dd4t</groupId>
        <artifactId>dd4t-caching</artifactId>
        <version>2.0.5</version>
    </dependency>
    <!--
        Caching configuration. For JMS,
        use this dependency. Minimum version is 5.10.0
    -->
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-client</artifactId>
        <version>5.10.0</version>
    </dependency>
    
    <!-- Caching configuration. Using the default EHCache -->
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
        <version>2.8.3</version>
    </dependency>
    
  2. Next, configure your web app to listen to incoming JMS messages. This is done in the Spring configuration of your webapp:

    <!--
        JMS Caching. Only turn this on if your deployer is configured 
        to use JMS.
        This implementation also requires a dependency on org.apache.activemq:activemq-client:5.10.0+
    
        Make sure to set the brokerURL, userName and password 
        properties in dd4t.properties,
        as well as the JMS topic in the listener config
     -->
    
    <bean id="cacheMessageListener" 
      class="org.dd4t.core.caching.jms.impl.JMSCacheMessageListener"/>
    <bean id="jmsExceptionListener" 
      class="org.dd4t.core.caching.jms.impl.JMSExceptionListener"/>
    <bean id="jmsCacheMonitor" 
      class="org.dd4t.core.caching.jms.impl.JMSCacheMonitor" />
    <bean id="jmsTransportListener" 
      class="org.dd4t.core.caching.jms.impl.JMSTransportListener"/>
    
    <bean id="connectionFactory" 
      class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="${jms.brokerUrl}"/>
        <property name="userName" value="${jms.userName}"/>
        <property name="password" value="${jms.password}"/>
        <property name="exceptionListener" ref="jmsExceptionListener"/>
        <property name="transportListener" ref="jmsTransportListener"/>
    </bean>
    
    <jms:listener-container container-type="default" destination-
      type="topic" connection-factory="connectionFactory" 
      acknowledge="auto">
        <jms:listener destination="${jms.topicName}" 
          ref="cacheMessageListener" method="onMessage"/>
    </jms:listener-container>
    
  3. Ensure you have ehcache.xml on your classpath. The default configuration looks like this:

    <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"           
    xsi:noNamespaceSchemaLocation="../../../../../../../spring-mvc-
    archetype/src/main/resources/archetype-
    resources/src/main/resources/schemas/ehcache.xsd">
        <!--
            Items that depend on other items stay in cache eternally. 
            They are expired by (un-)publishing the dependent item.
            Items that don't depend on other items stay in cache for 
            TTL & TTI defined below.
            All items are evicted from cache based on LRU policy when 
            cache is full.
    
            TTL 3600 = 1 hour
            TTI 60 = 1 min
        -->
        <cache name="DD4T-Objects"
               eternal="false"
               maxEntriesLocalHeap="10000"
               timeToLiveSeconds="3600"
               timeToIdleSeconds="60"
               memoryStoreEvictionPolicy="LRU">
        </cache>
        <cache name="DD4T-Dependencies"
               maxEntriesLocalHeap="50000"
               memoryStoreEvictionPolicy="LRU">
        </cache>
    </ehcache>
    

If both the Tridion Object Cache and the DD4T Cache are enabled, the TOC will cache all Tridion related objects as it normally would. The TOC does not us EHCache for this, but it's own internal cache.

The DD4T cache stores something different: the deserialized DD4T objects and their dependent objects in it's own EHCache based cache.

  • Hi Raimond; Thanks; this helps a lot to clarify the doubts; provide road map to proceed/decision making; If comparing TOC and DD4T cache benfits (for a website based on DD4T framework) to increase the performance of website and make page load faster; what should be the rough stats to judge both. Say TOC can increase website performance by 30% and DD4T cache can increase performance by 70% on avg case or TOC has no impact on performance when its DD4T based web-application and only DD4T cache is the key player to improve performance. Any thoughts on same ? – Gulshan Thakur Apr 26 '17 at 6:27
  • If you turn on the DD4T cache, it will be the main player to improve performance as it will be the primary cache where objects are fetched from. Turning both on essentially is not required as both caches will be invalidated at the same time for items. However for things like linking and dynamic queries you could leave the TOC on. Improvment percentages really depend on your implementation and you can't compare TOC with DD4T's cache as they serve different purposes. For DD4T websites you should always turn on the DD4T cache. – Raimond Apr 26 '17 at 10:14
  • Hi Raymond; Step#2 "Configure your web app to listen to incoming JMS messages" mentioned by you above is specific to ActiveMQ, can you help me to configure same for OSB (as JMS Server). I am looking specifically what to define for bean id="connectionFactory" and bean id="jmsTransportListener" when its OSB and not ActiveMQ. I hope other configurations mentioned above are generic to use for any JMS. – Gulshan Thakur Jun 1 '17 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.