Chapter 23 884 Unsubscribing from a Topic When the session is closed, the JMS Provider will automatically unsubscribe any non-durable subscriptions created during the session. A client that has subscribed to a durable topic may explicitly unsubscribe from that topic with the unsubscribe(String topicName) method which takes a single parameter of type String. The single parameter is the same name that is sent to the createDurableSubscription() method when the subscription is created. The WeblogicJMSDetails Class This code contains all the constants for this example, as well as the JNDI connection: package common; import javax.naming.*; import java.util.Properties; public class WeblogicJMSDetails { The constants that are used to locate the JMS server, the connection factory, the topic (and queue, which will be used in the next example), and the JNDI factory are described below. Note that the JNDI_FACTORY and EJB_SERVER constants are vendor-specific (in this case they are Weblogic-specific) and should be changed according to which JMS vendor you are using:     public final static String EJB_SERVER = "t3://127.0.0.1:7001";     public final static String JMS_CONNECTION_FACTORY = "MyJMSConnectionFactory";     public final static String TOPIC_NAME = "MyJMSTopic";     public final static String QUEUE_NAME = "MyJMSQueue";     public final static String JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory";   /**    * The initial context    */   private static InitialContext ctx = null;   /**    * Creates a connection to the JNDI    */   public static InitialContext getInitialContext() throws NamingException   { The first thing that the publisher's constructor does is to create an initial context. The context properties are specific to the JMS provider, but here is how the context creation looks for BEA's Weblogic 6.0 application server:     if(WeblogicJMSDetails.ctx == null){       Properties env = new Properties();       env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);       env.put(Context.PROVIDER_URL, EJB_SERVER);       env.put("weblogic.jndi.createIntermediateContexts", "true");       ctx = new InitialContext(env);     }     return ctx;   } }