コード例 #1
0
  /** Tasks to be carried out in the STARTUP_EVENT. Logs a message */
  private void onStartTask() {
    ctx.log("LifecycleTopic: STARTUP_EVENT");
    // my code
    QueueSession qsession[] = new QueueSession[10];
    Queue queue[] = new Queue[10];

    try {
      for (int i = 0; i < 10; i++) {
        // Get initial context
        ctx.log("Get initial context");
        InitialContext initialContext = new InitialContext();

        // look up the connection factory from the object store
        ctx.log("Looking up the queue connection factory from JNDI");
        QueueConnectionFactory factory =
            (QueueConnectionFactory) initialContext.lookup("jms/QCFactory");

        // look up queue from the object store
        ctx.log("Create queue connection");
        QueueConnection qconn = factory.createQueueConnection();

        ctx.log("Create queue session");
        qsession[i] = qconn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

        ctx.log("Looking up the queue from JNDI");
        queue[i] = (Queue) initialContext.lookup("jms/SampleQueue");
      }

      updateDB();

    } catch (Exception e) {
      ctx.log("Exception caught in test code");
      e.printStackTrace();
    }

    // end my code

    // my code
    // createAccount();
    // end my code
  }