2 Replies Latest reply: Feb 27, 2013 9:36 AM by Brian Oliver RSS

    Is it possible to catch ConnectionException in PublishingCacheStore

    743678
      Hi All,

      We are using 3 clusters of coherence; where data flow is always one way, i.e Master Cache writes to 2 other redundant caches (these caches are read only.. No writes are expected in these things). We are using PublishingCacheStore along with EventDistribution pattern.

      We have written our own CacheStore which extends PublishingCacheStore (of Push Replication Pattern). Everything works fine. In case of failover, i.e. if there is a connectionException to remote cluster we are not able to catch that exception. However we could see the exception in the system console.

      Please let me know if anyone has any idea how to do it.

      CacheStore Implementation:
      ==================

      @Override
           public void store(BinaryEntry entry) {
                if(logger.isDebugEnabled()) logger.debug("Entry >> store entry "+entry+" for channelName "+channelName+" & cacheName "+cacheName);
                try {
                     super.store(entry);
                }catch (ConnectionException e) {
                     logger.error("ConnectionException occured while store (replicating) the data to channelName "+channelName+" for cacheName "+cacheName,e);
      //Some business logic needs to be added on Exception
                     //Throwing back the exception to make sure that the replicated failure data is requeued again.
                     throw new RuntimeException(e);
                }
                catch (Exception e) {
                     logger.error("Exception occured while store (replicating) the data to channelName "+channelName+" for cacheName "+cacheName,e);
                     //Some business logic needs to be added on Exception
                     //Throwing back the exception to make sure that the replicated failure data is requeued again.
                     throw new RuntimeException(e);
                }
           }

      Coherence cache Config.xml
      =================
      <cache-mapping>
           <cache-name>TEST</cache-name>
                <scheme-name>CacheDB</scheme-name>
                     <event:distributor>
                          <event:distributor-name>{cache-name}</event:distributor-name>
                          <event:distributor-external-name>{site-name}-{cluster-name}-{cache-name}</event:distributor-external-name>

                          <event:distributor-scheme>
                               <event:coherence-based-distributor-scheme />
                          </event:distributor-scheme>

                          <event:distribution-channels>
                               <event:distribution-channel>
                                    <event:channel-name>Active Publisher 1</event:channel-name>
                                    <event:starting-mode system-property="channel.starting.mode">enabled</event:starting-mode>
      <event:restart-delay>12000</event:restart-delay>
                                    <event:channel-scheme>
                                         <event:remote-cluster-channel-scheme>
                                              <event:remote-invocation-service-name>remote-site1</event:remote-invocation-service-name>
                                              <event:remote-channel-scheme>
                                                   <event:local-cache-channel-scheme>
                                                        <event:target-cache-name>TEST</event:target-cache-name>
                                                   </event:local-cache-channel-scheme>
                                              </event:remote-channel-scheme>
                                         </event:remote-cluster-channel-scheme>
                                    </event:channel-scheme>
                               </event:distribution-channel>

                               <event:distribution-channel>
                                    <event:channel-name>Active Publisher 2</event:channel-name>
                                    <event:starting-mode system-property="channel.starting.mode">enabled</event:starting-mode>
      <event:restart-delay>12000</event:restart-delay>
                                    <event:channel-scheme>
                                         <event:remote-cluster-channel-scheme>
                                              <event:remote-invocation-service-name>remote-site2</event:remote-invocation-service-name>
                                              <event:remote-channel-scheme>
                                                   <event:local-cache-channel-scheme>
                                                        <event:target-cache-name>TEST</event:target-cache-name>
                                                   </event:local-cache-channel-scheme>
                                              </event:remote-channel-scheme>
                                         </event:remote-cluster-channel-scheme>
                                    </event:channel-scheme>
                               </event:distribution-channel>
                               
                                    
                          </event:distribution-channels>
                     </event:distributor>
                </cache-mapping>

      </caching-scheme-mapping>
           <!--
                     The following scheme is required for each remote-site when using a
                     RemoteInvocationPublisher
                -->
           <remote-invocation-scheme>
           <service-name>remote-site1</service-name>
                     <initiator-config>
                          <tcp-initiator>
                               <remote-addresses>
                                    <socket-address>
                                         <address>localhost</address>
                                         <port>20001</port>
                                    </socket-address>
                               </remote-addresses>
                               <connect-timeout>2s</connect-timeout>
                          </tcp-initiator>
                          <outgoing-message-handler>
                               <request-timeout>5s</request-timeout>
                          </outgoing-message-handler>
                     </initiator-config>
                </remote-invocation-scheme>

                <remote-invocation-scheme>
                     <service-name>remote-site2</service-name>
                     <initiator-config>
                          <tcp-initiator>
                               <remote-addresses>
                                    <socket-address>
                                         <address>localhost</address>
                                         <port>20002</port>
                                    </socket-address>
                               </remote-addresses>
                               <connect-timeout>2s</connect-timeout>
                          </tcp-initiator>
                          <outgoing-message-handler>
                               <request-timeout>5s</request-timeout>
                          </outgoing-message-handler>
                     </initiator-config>
                </remote-invocation-scheme>

                <distributed-scheme>
                     <scheme-name>UserCacheDB</scheme-name>
                     <service-name>DistributedCache</service-name>
                     <serializer>
                          <class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
                          <init-params>
                               <init-param>
                                    <param-type>String</param-type>
                                    <param-value>pof-config.xml</param-value>
                               </init-param>
                          </init-params>
                     </serializer>
                     <backing-map-scheme>
      <read-write-backing-map-scheme>
      <internal-cache-scheme>
      <local-scheme>
      </local-scheme>
      </internal-cache-scheme>
      <cachestore-scheme>
      <class-scheme>
      <class-name>au.com.vha.cpg.cachestore.publishing.CPGPublishingCacheStore</class-name>
      <init-params>
      <init-param>
      <param-type>java.lang.String</param-type>
      <param-value>{cache-name}</param-value>
      </init-param>
                                              <init-param>
      <param-type>java.lang.String</param-type>
      <param-value>TEST</param-value>
      </init-param>
      </init-params>
      </class-scheme>
      </cachestore-scheme>
      </read-write-backing-map-scheme>
      </backing-map-scheme>
                     <listener />
                     <autostart>true</autostart>
                </distributed-scheme>