⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 topicmanager.java

📁 BEA WebLogic Server 8.1大全 = BEA webLogic server 8.1 unleashed (美) Mark Artiges等著 袁毅 ... [等] 译 eng
💻 JAVA
字号:
package com.wls8unleashed.jms;

import javax.jms.*;
import javax.naming.*;

/**
 * Provides common initialization work used for Topic
 * subscribers and publishers.
 */
public class TopicManager {

  protected TopicConnectionFactory topicConnectionFactory;
  protected TopicConnection topicConnection;
  protected TopicSession topicSession;
  protected Topic topic;

	/**
	 * Creates and initializes a bunch of topic resources.
	 */
  public TopicManager(Context context){
    try{    
      // Get JMS factory JNDI name
      String jmsFactoryName = Props.get("jms.factory.for.topic");
  
      // Create topic connection factory
      System.out.println("Looking up factory name: " + jmsFactoryName);
      topicConnectionFactory =
        (TopicConnectionFactory) context.lookup(jmsFactoryName);
  
      // Create topic connection to the factory
      System.out.println("Creating topic connection...");
      topicConnection = topicConnectionFactory.createTopicConnection();
  
      // Create session to the connection
      System.out.println("Creating topic session...");
      topicSession = topicConnection.createTopicSession(
                                      false, Session.AUTO_ACKNOWLEDGE);
  
      // Get topic name
      String topicName = Props.get("topic.name");
  
      // Lookup handle to the Topic
      try {
      	System.out.println("Looking up topic name: " + topicName);
        topic = (Topic) context.lookup(topicName);
      } catch (NamingException namingException) {
        // If not created, create new topic, and bind topic to name
        System.out.println("Didn't find the topic...so creating: " + topicName);
        topic = topicSession.createTopic(topicName);
        System.out.println("Binding topic: " + topicName);
        context.bind(topicName, topic);
      }
    }
    catch(Exception e){
      System.out.println("PROBLEM CREATING TOPIC MANAGER");
      e.printStackTrace();
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -