Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

TIBCO EMS and Ehcache Replication

Developers
2009-09-02
2013-05-14
  • jawaid hakim
    jawaid hakim
    2009-09-02

    Just got Ehcache's JMS replication working with TIBCO EMS.

    It is quite straightforward - make sure that all topics, queues, factories that take part in Ehcache replication are administered EMS artifacts (i.e. pre-defined in EMS configuration files), then implement the EMS initial context provider as shown below, and configure Ehcache JMS replication are described in the Ehcache documentation:

    package com.codestreet.bs.services.impl.rules;

    import java.util.Hashtable;

    import javax.naming.Context;
    import javax.naming.NamingException;

    import com.tibco.tibjms.naming.TibjmsInitialContextFactory;

    /**
    * EMS initial context factory for JMS replicated Ehcache.
    *
    * @author jhakim
    *
    */
    public class EMSInitialContextFactory extends TibjmsInitialContextFactory
    {
        @SuppressWarnings("unchecked")
        @Override
        public Context getInitialContext(final Hashtable env)
                throws NamingException
        {
            Hashtable<String, Object> data = new Hashtable<String, Object>(env);
            data.put(Context.INITIAL_CONTEXT_FACTORY,
                    "com.tibco.tibjms.naming.TibjmsInitialContextFactory");
            data.put(Context.URL_PKG_PREFIXES, "com.tibco.tibjms.naming");
            data.put(Context.PROVIDER_URL, "tibjmsnaming://localhost:7222");
            data.put(Context.SECURITY_PRINCIPAL, "tw_acme_emissary");
            Context ctx = super.getInitialContext(data);
            return ctx;
        }
    }

     
    • jawaid hakim
      jawaid hakim
      2009-09-02

      The SECURITY_PRINCIPAL should be set to a valid EMS user for your environment:

      import java.util.Hashtable;

      import javax.naming.Context;
      import javax.naming.NamingException;

      import com.tibco.tibjms.naming.TibjmsInitialContextFactory;

      /**
      * EMS initial context factory for JMS replicated Ehcache.

      * @author jhakim

      */
      public class EMSInitialContextFactory extends TibjmsInitialContextFactory
      {
      @SuppressWarnings("unchecked")
      @Override
      public Context getInitialContext(final Hashtable env)
      throws NamingException
      {
      Hashtable<String, Object> data = new Hashtable<String, Object>(env);
      data.put(Context.INITIAL_CONTEXT_FACTORY,
      "com.tibco.tibjms.naming.TibjmsInitialContextFactory");
      data.put(Context.URL_PKG_PREFIXES, "com.tibco.tibjms.naming");
      data.put(Context.PROVIDER_URL, "tibjmsnaming://localhost:7222");
      data.put(Context.SECURITY_PRINCIPAL, principal);
      Context ctx = super.getInitialContext(data);
      return ctx;
      }
      }

       
      • Greg Luck
        Greg Luck
        2009-09-03

        Great news. I will write this up in the JMS documentation and get you to check it.

         
    • jawaid hakim
      jawaid hakim
      2009-09-10

      Sure. Send me the docs when you are ready for review.