public void run() {
   MessageConsumer consumer = null;
   try {
     consumer =
         session.createConsumer(
             responseQueue,
             " " + TaskServiceConstants.SELECTOR_NAME + " like '" + selector + "%' ");
     ObjectMessage serverMessage = (ObjectMessage) consumer.receive();
     if (serverMessage != null) {
       ((JMSTaskClientHandler) handler)
           .messageReceived(session, readMessage(serverMessage), responseQueue, selector);
     }
   } catch (JMSException e) {
     if (!"102".equals(e.getErrorCode())) {
       throw new RuntimeException("No se pudo recibir respuesta JMS", e);
     }
     logger.info(e.getMessage());
     return;
   } catch (Exception e) {
     throw new RuntimeException("Error inesperado recibiendo respuesta JMS", e);
   } finally {
     if (consumer != null) {
       try {
         consumer.close();
       } catch (Exception e) {
         logger.info("No se pudo cerrar el consumer: " + e.getMessage());
       }
     }
   }
 }
  public DigitalLibraryServer() {
    try {
      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
      properties.put(Context.PROVIDER_URL, "localhost");

      InitialContext jndi = new InitialContext(properties);
      ConnectionFactory conFactory = (ConnectionFactory) jndi.lookup("XAConnectionFactory");
      connection = conFactory.createConnection();

      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

      try {
        counterTopic = (Topic) jndi.lookup("counterTopic");
      } catch (NamingException NE1) {
        System.out.println("NamingException: " + NE1 + " : Continuing anyway...");
      }

      if (null == counterTopic) {
        counterTopic = session.createTopic("counterTopic");
        jndi.bind("counterTopic", counterTopic);
      }

      consumer = session.createConsumer(counterTopic);
      consumer.setMessageListener(this);
      System.out.println("Server started waiting for client requests");
      connection.start();
    } catch (NamingException NE) {
      System.out.println("Naming Exception: " + NE);
    } catch (JMSException JMSE) {
      System.out.println("JMS Exception: " + JMSE);
      JMSE.printStackTrace();
    }
  }
  void processTask(ETask task, ObjectMessage msg, EntityManager em) {
    EMethod method;
    EModel model;
    Collection<EBounds> bounds;
    TaskMessage tm;

    System.out.println("Processing task [id=" + String.valueOf(task.getId()) + "]...");

    method = task.getMethod();
    model = task.getModel();
    bounds = getBoundsForModel(model, em);

    try {
      tm = (TaskMessage) msg.getObject();
      if (method.getIdent().equals(EMethod.fba)) {
        FbaMethod.run(task, model, bounds);
      } else if (method.getIdent().equals(EMethod.fva)) {
        FvaMethod.run(task, model, bounds, (MultipleReactionsTaskMessage) tm);
      } else if (method.getIdent().equals(EMethod.rscan)) {
        RscanMethod.run(task, model, bounds, (MultipleReactionsTaskMessage) tm);
      } else if (method.getIdent().equals(EMethod.kgene)) {
        KgeneMethod.run(task, model, bounds);
      }
      msg.acknowledge();
    } catch (AmkfbaException e) {
      AcornLogger.logError("AmkfbaException: " + e.getMessage());
      markAsBroken(task, em);
    } catch (JMSException e) {
      e.printStackTrace(System.err);
      throw new Error("JMSException, aborting...");
    }
  }
示例#4
0
  @Override
  public void onMessage(Message message) {
    if (!(message instanceof ObjectMessage)) {
      return;
    }

    try {
      Object objectInMessage = ((ObjectMessage) message).getObject();
      if (!(objectInMessage instanceof LectureWrapperDTO)) {
        return;
      }

      final String messageAction = message.getStringProperty("action");
      if (messageAction == null) {
        return;
      }
      LectureWrapperDTO lectureWrapperDTO = (LectureWrapperDTO) objectInMessage;

      if (messageAction.equals(ISchedulerListener.InfoType.CREATED.toString())) {
        schedulerListener.notify(ISchedulerListener.InfoType.CREATED, lectureWrapperDTO);
      } else if (messageAction.equals(ISchedulerListener.InfoType.INFO.toString())) {
        schedulerListener.notify(ISchedulerListener.InfoType.INFO, lectureWrapperDTO);
      } else if (messageAction.equals(ISchedulerListener.InfoType.DENIED.toString())) {
        schedulerListener.notify(ISchedulerListener.InfoType.DENIED, lectureWrapperDTO);
      } else if (messageAction.equals(ISchedulerListener.InfoType.STREAMED.toString())) {
        schedulerListener.notify(ISchedulerListener.InfoType.STREAMED, lectureWrapperDTO);
      }
    } catch (JMSException e) {
      e.printStackTrace();
    }
  }
  /**
   * Message listener interface.
   *
   * @param msg message
   */
  public void onMessage(Message msg) {
    try {
      String msgText;
      if (msg instanceof TextMessage) {
        msgText = ((TextMessage) msg).getText();
      } else {
        msgText = msg.toString();
      }

      // System.out.println("Message Received: "+ msgText );
      // ClientTools clientTools = new ClientTools();

      // ClientTools.getRequestAsFile(msgText);
      // DataTools dataTools = new DataTools();
      NonCimDataTools nonCimDataTools = new NonCimDataTools();

      if (!nonCimDataTools.deleteOperation(msgText)) {
        // ClientTools.getDataAsFile(msgText);
        nonCimDataTools.rdfToConsole(msgText);
      }
      // System.out.println("OK");

      if (msgText.equalsIgnoreCase("quit")) {
        synchronized (this) {
          quit = true;
          this.notifyAll(); // Notify main thread to quit
        }
      }
    } catch (JMSException jmse) {
      jmse.printStackTrace();
    }
  }
 @Override
 protected void doGet(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
   resp.setContentType("text/html");
   PrintWriter out = resp.getWriter();
   Connection connection = null;
   out.write("<h1>Produce JMS ObjectMessages</h1>");
   try {
     connection = connectionFactory.createConnection();
     Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
     MessageProducer producer = session.createProducer(queue);
     ObjectMessage message = session.createObjectMessage();
     MyResource resource = new MyResource("This is my resource");
     message.setObject(resource);
     producer.send(message);
     out.write("<p>Send JMS Message with object: " + resource + "</p>");
   } catch (JMSException e) {
     e.printStackTrace();
     out.write("<h2>A problem occurred during the delivery of this message</h2>");
     out.write("</br>");
     out.write(
         "<p><i>Go your the JBoss Application Server console or Server log to see the error stack trace</i></p>");
   } finally {
     if (connection != null) {
       try {
         connection.close();
       } catch (JMSException e) {
         e.printStackTrace();
       }
     }
     if (out != null) {
       out.close();
     }
   }
 }
示例#7
0
 private void publishControllerPendingEvents() {
   isRunning = true;
   lastRun = System.currentTimeMillis();
   List<CMSEvent> events = controllerEventReader.getEvents();
   while (events.size() > 0) {
     logger.info("Got " + events.size() + " controller events; Using ControllerEventPublisher");
     for (CMSEvent event : events) {
       try {
         if (event.getPayload() != null) {
           eventPublisher.publishControllerEvents(event);
         } else {
           logger.info("Event payload found null for " + event.getHeaders());
         }
         controllerEventReader.removeEvent(event.getEventId());
       } catch (JMSException e) {
         e.printStackTrace();
         logger.error(e.getMessage(), e);
         // stopPublishing();
         return;
       }
     }
     events = controllerEventReader.getEvents();
   }
   // System.out.println("Done;");
 }
    public void onMessage(Message message) {
      if (!started) {
        startLatch.countDown();
        started = true;
      }
      try {
        int foo = message.getIntProperty("foo");
        if (foo != count) {
          e = new Exception("received out of order expected " + count + " received " + foo);
          failed = true;
          conn.close();
        }
        count++;
      } catch (JMSException e) {

        this.e = e;
        failed = true;
        try {
          conn.close();
        } catch (JMSException e1) {
          e1
              .printStackTrace(); // To change body of catch statement use File | Settings | File
                                  // Templates.
        }
      }
    }
示例#9
0
  public QLender(String queuecf, String requestQueue) {
    try {
      // Connect to the provider and get the JMS connection
      Context ctx = new InitialContext();
      QueueConnectionFactory qFactory = (QueueConnectionFactory) ctx.lookup(queuecf);
      qConnect = qFactory.createQueueConnection();

      // Create the JMS Session
      qSession = qConnect.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

      // Lookup the request queue
      requestQ = (Queue) ctx.lookup(requestQueue);

      // Now that setup is complete, start the Connection
      qConnect.start();

      // Create the message listener
      QueueReceiver qReceiver = qSession.createReceiver(requestQ);
      qReceiver.setMessageListener(this);

      System.out.println("Waiting for loan requests...");

    } catch (JMSException jmse) {
      jmse.printStackTrace();
      System.exit(1);
    } catch (NamingException jne) {
      jne.printStackTrace();
      System.exit(1);
    }
  }
示例#10
0
  /** @see MessageListener#onMessage(Message) */
  public void onMessage(Message message) {

    TextMessage tmsg = null;
    tmsg = (TextMessage) message;
    String parameter0 = null;
    String parameter1 = null;
    System.out.println("<sms module>");

    // parsing message into opcode, and parameters
    String preParse;
    try {
      preParse = tmsg.getText();
      String[] postParse = preParse.split("[|]+");
      parameter0 = postParse[0];
      parameter1 = postParse[1];

    } catch (JMSException e1) {
      e1.printStackTrace();
    }

    try {
      // TODO
      sendSMS(parameter0, parameter1);
    } catch (Exception e) {

      e.printStackTrace();
    }
  }
 public int read(byte[] buffer) throws IOException {
   try {
     return _message.readBytes(buffer);
   } catch (JMSException e) {
     throw new IOException(e.toString());
   }
 }
示例#12
0
  public void createJMSObject() throws Config4JMSException {
    Queue queue;
    Session session;

    session = creator.getSession();
    try {
      // --------
      // One of the following:
      //    createBrowser(queue)
      //    createBrowser(queue, messageSelector)
      // --------
      queue = config4jms.getQueue(createQueue);
      if (createMessageSelector == null) {
        queueBrowser = (QueueBrowser) session.createBrowser(queue);
      } else {
        queueBrowser = (QueueBrowser) session.createBrowser(queue, createMessageSelector);
      }
    } catch (JMSException ex) {
      throw new Config4JMSException(
          ex,
          cfg.fileName()
              + ": error in "
              + "creating object for "
              + scope
              + "; Session.createConsumer() failed: "
              + ex.toString());
    }
  }
示例#13
0
  @Override
  public void test() throws JMSException {
    MessageProducer producer = _session.createProducer(_queue);

    Message message = _session.createTextMessage("Message");

    producer.send(message);

    _logger.info("Calling Commit");

    long start = System.nanoTime();
    try {
      _session.commit();
      fail("Commit occured even though syncWait timeout is shorter than delay in commit");
    } catch (JMSException e) {
      assertTrue(
          "Wrong exception type received.", e.getLinkedException() instanceof AMQTimeoutException);
      assertTrue(
          "Wrong message received on exception.", e.getMessage().startsWith("Failed to commit"));
      // As we are using Nano time ensure to multiply up the millis.
      assertTrue(
          "Timeout was more than 30s default",
          (System.nanoTime() - start) < (1000000L * 1000 * 30));
    }
  }
  public void onMessage(Message inMessage) {
    TextMessage msg = null;

    try {
      if (inMessage instanceof TextMessage) {
        msg = (TextMessage) inMessage;
        System.out.println("MESSAGE BEAN: Message received: " + msg.getText());
        long sleepTime = msg.getLongProperty("sleeptime");
        System.out.println("Sleeping for : " + sleepTime + " milli seconds ");
        Thread.sleep(sleepTime);
        queueConnection = queueConnectionFactory.createQueueConnection();
        queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        queueSender = queueSession.createSender(queue);
        TextMessage message = queueSession.createTextMessage();

        message.setText("REPLIED:" + msg.getText());
        message.setIntProperty("replyid", msg.getIntProperty("id"));
        System.out.println("Sending message: " + message.getText());
        queueSender.send(message);
      } else {
        System.out.println("Message of wrong type: " + inMessage.getClass().getName());
      }
    } catch (JMSException e) {
      e.printStackTrace();
    } catch (Throwable te) {
      te.printStackTrace();
    } finally {
      try {
        queueSession.close();
        queueConnection.close();
      } catch (Exception e) {
      }
    }
  } // onMessage
示例#15
0
  @Override
  public boolean sacar(int id, double valor) {

    GenericDAO servico = new ContaDAO();

    double novoSaldo;
    List<Conta> lista = buscarConta();
    for (Conta conta : lista) {
      if (conta.getIdConta().equals(id)) {

        if (conta.getSaldo() < valor) {
          return false;
        } else {
          novoSaldo = conta.getSaldo() - valor;
          conta.setSaldo(novoSaldo);
          servico.update(conta);
          try {
            producesSB.sendMessage(
                "Saque em (" + conta.getNomeConta() + ") bem sucedido: você sacou R$" + valor);
          } catch (JMSException ex) {
            System.out.println(ex.getMessage());
          }
        }
      }
    }

    return true;
  }
  public void init(
      Connection connection,
      String queue,
      boolean isTopic,
      MessageListener mlisten,
      boolean isActive) {
    try {
      // Session: 一个发送或接收消息的线程
      session = connection.createSession(Boolean.FALSE, Session.AUTO_ACKNOWLEDGE);
      if (isTopic) {
        destination = session.createTopic(queue);
      } else {
        destination = session.createQueue(queue);
      }

      consumer = session.createConsumer(destination);
      if (isActive) {
        System.out.println(queue);
        LogSys.nodeLogger.info("创建一个主动方式获取消息的Receiver:" + queue);
      } else {
        if (mlisten == null) consumer.setMessageListener(this);
        else consumer.setMessageListener(mlisten);
      }
    } catch (JMSException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  /**
   * Send a command via JMS.
   *
   * <p>Note: Opens and closes the connection per invocation of this method which, when run outside
   * a JavaEE container, is not very efficient.
   *
   * @param command
   * @throws JMSException
   */
  public void sendCommandMessage(Command command) throws JMSException {
    Connection connection = null;
    Session session = null;
    try {
      connection = connectionFactory.createConnection();
      session = connection.createSession(TRANSACTIONAL, Session.AUTO_ACKNOWLEDGE);

      // Construct a JMS "TextMessage"
      final TextMessage newMessage = session.createTextMessage();
      newMessage.setStringProperty("issuer", command.getIssuer());
      newMessage.setStringProperty("type", command.getType());
      newMessage.setText(command.getPayload());

      // Send the message
      final MessageProducer producer = session.createProducer(this.commandQueue);
      producer.send(newMessage);

      if (TRANSACTIONAL) {
        // JavaEE containers would manage this
        session.commit();
      }
    } finally {
      if (connection != null) {
        try {
          if (session != null) {
            session.close();
          }
          connection.stop();
          connection.close();
        } catch (JMSException e) {
          e.printStackTrace();
        }
      }
    }
  }
示例#18
0
 public void start() {
   try {
     conn.start();
   } catch (JMSException e) {
     e.printStackTrace();
   }
 }
  /**
   * @see MessageListener#onMessage(Message)
   *     <p>This method expects a MapMessage containing information about a flight that has been
   *     added to the database. This method will print out the information about the flight.
   */
  public void onMessage(Message message) {
    try {
      if (message instanceof MapMessage) {
        MapMessage msg = (MapMessage) message;

        StringBuffer sb = new StringBuffer();

        sb.append("Flight #: " + msg.getString("flightId") + "\n");
        sb.append("Flight Date: " + msg.getString("flightDate") + "\n");
        sb.append("Departure Airport: " + msg.getString("departureAirport") + "\n");
        sb.append("Destination Airport: " + msg.getString("destinationAirport") + "\n");
        sb.append("Number of Seats: " + msg.getInt("numSeats") + "\n");
        sb.append("Seat Cost: $" + msg.getDouble("cost") + "\n");
        sb.append("Airplane #: " + msg.getString("airplaneId") + "\n");
        sb.append("*************************************************** \n\n");

        System.out.println(
            "\n**" + getClass().getSimpleName() + ": Flight Added!\n" + sb.toString());

      } else {
        System.out.println(
            getClass().getSimpleName()
                + " - Error: The message provided was not of type MapMessage!");
      }
    } catch (JMSException e) {
      System.out.println(
          getClass().getSimpleName() + ": Error occuredwhen attempting to read the MapMessage");
      e.printStackTrace();
    }
  }
示例#20
0
  @Override
  public void blogracyContentReceived(BlogracyContent message) {
    if (message == null) return;

    TextMessage response;
    try {
      response = session.createTextMessage();

      JSONObject record = new JSONObject();
      record.put("request", "contentReceived");
      record.put("senderUserId", message.getSenderUserId());
      record.put("contentRecipientUserId", message.getContentRecipientUserId());

      JSONObject content = new JSONObject(message.getContent());
      record.put("contentData", content);
      record.put("contentId", content.getJSONObject("object").getString("id"));

      response.setText(record.toString());

      producer.send(outgoingQueue, response);
    } catch (JMSException e) {
      e.printStackTrace();
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
示例#21
0
 private void publishCIPendingEvents() {
   // logger.info("start reading" + eventType);
   isRunning = true;
   lastRun = System.currentTimeMillis();
   List<CMSEvent> events = ciEventReader.getEvents();
   while (events.size() > 0) {
     logger.info("Got " + events.size() + " ci events; Using CIEventPublisher");
     for (CMSEvent event : events) {
       String action = event.getHeaders().get("action");
       try {
         if (event.getPayload() != null || "delete".equals(action)) {
           eventPublisher.publishCIEvents(event);
         } else {
           logger.info("Event payload found null for " + event.getHeaders());
         }
         ciEventReader.removeEvent(event.getEventId());
       } catch (JMSException e) {
         e.printStackTrace();
         logger.error(e.getMessage(), e);
         // stopPublishing();
         return;
       }
     }
     events = ciEventReader.getEvents();
   }
   // System.out.println("Done;");
 }
示例#22
0
  public void testDurableWithQueueThrowsException() throws Exception {
    Jms11Support jmsSupport = new Jms11Support(new JmsConnector(), null, false, false);

    Mock mockQueue = new Mock(Queue.class);
    Queue queue = (Queue) mockQueue.proxy();

    String durableName = "durableName";
    boolean noLocal = true;

    Mock mockSession = new Mock(Session.class);

    try {
      jmsSupport.createConsumer(
          (Session) mockSession.proxy(), queue, null, noLocal, durableName, false);
    } catch (JMSException jmsex) {
      // expected
      assertEquals(
          "Wrong exception text.",
          "A durable subscriber name was set but the destination was not a Topic",
          jmsex.getMessage());
    }

    mockQueue.verify();
    mockSession.verify();
  }
示例#23
0
  @Override
  public void onMessage(Message msg) {
    try {
      if (!msg.propertyExists(AppConsts.MESSAGE_TYPE) || !(msg instanceof TextMessage)) {
        throw new IOError(null);
      }
      String type = msg.getStringProperty(AppConsts.MESSAGE_TYPE);
      if (type.equals(AppConsts.CHANGE_BALANCE_MT)) {
        String text = ((TextMessage) msg).getText();
        ChangeBalanceDTO dto = null;
        try {
          dto = ju.fromXml(text, ChangeBalanceDTO.class);
        } catch (Exception e) {
          log.error("Could not convert xml to object", e);
          throw new IOError(null);
        }
        if (db.changeBalance(dto.getPhoneNumber(), dto.getDelta()) == null) {
          throw new IOError(null);
        }

      } else {
        throw new IOError(null);
      }
    } catch (IOError e) {
      forwardMessageToNone(msg);
    } catch (JMSException e) {
      log.trace(e.getMessage(), e);
    }
  }
  public void onMessage(final Message message) {
    try {
      // Step 9. We know the client is sending a text message so we cast
      TextMessage textMessage = (TextMessage) message;

      // Step 10. get the text from the message.
      String text = textMessage.getText();

      System.out.println("message " + text + " received");

      if (!textMessage.getJMSRedelivered()) {
        // Step 11. On first delivery get the transaction, take a look, and throw an exception
        Transaction tx = tm.getTransaction();

        if (tx != null) {
          System.out.println("something is wrong, there should be no global transaction: " + tx);
        } else {
          System.out.println(
              "there is no global transaction, although the message delivery is using a local transaction");
          System.out.println("let's throw an exception and see what happens");
          throw new RuntimeException("DOH!");
        }
      } else {
        // Step 12. Print the message
        System.out.println(
            "The message was redelivered since the message delivery used a local transaction");
      }

    } catch (JMSException e) {
      e.printStackTrace();
    } catch (SystemException e) {
      e.printStackTrace();
    }
  }
示例#25
0
文件: Produces.java 项目: ITA-G03/O2O
  public void sendMessage(Order order) {
    ConnectionFactory factory = new ActiveMQConnectionFactory("failover://tcp://localhost:61616");
    Queue queue = new ActiveMQQueue("sequence");
    Connection conn = null;
    Session sen = null;
    MessageProducer producer = null;
    TextMessage msg = null;
    JSONMapper mapper = new JSONMapper();

    Destination des = null;
    try {
      conn = factory.createConnection();
      sen = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      producer = sen.createProducer(queue);
      conn.start();
      String str = mapper.writeObjectAsString(order);
      System.out.println(str);
      msg = sen.createTextMessage(str);
      producer.send(msg);
      producer.close();
      sen.close();
      conn.close();
    } catch (JMSException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  public void doSend() {

    QueueSession queueSession = null;
    QueueSender queueSender = null;
    TextMessage message = null;

    if (doSetup()) {

      try {
        queueConnection = queueConnectionFactory.createQueueConnection();
        queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        queueSender = queueSession.createSender(queue);
        message = queueSession.createTextMessage();
        for (int i = 0; i < NUM_MSGS; i++) {
          message.setText("This is message " + (i + 1));
          System.out.println("Sending message: " + message.getText());
          queueSender.send(message);
        }

        /*
         * Send a non-text control message indicating end of messages.
         */
        queueSender.send(queueSession.createMessage());
      } catch (JMSException e) {
        log.error("JMS Send Exception occurred: " + e.toString());
      } finally {
        doCleanup();
      }
    }
  }
示例#27
0
 private void closeReceiver() {
   try {
     connection.close();
   } catch (JMSException e) {
     e.printStackTrace(System.err);
   }
 }
  /** use auto acknowledge which automatically has the client say OK */
  public void doReceiveAuto() {

    if (doSetup()) {
      try {
        queueConnection = queueConnectionFactory.createQueueConnection();
        QueueSession queueSession =
            queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        QueueReceiver queueReceiver = queueSession.createReceiver(queue);
        queueConnection.start();
        while (true) {
          Message m = queueReceiver.receive(1);
          if (m != null) {
            if (m instanceof TextMessage) {
              TextMessage message = (TextMessage) m;
              log.debug("Reading message:==> " + message.getText());
            } else {
              break;
            }
          }
        }
      } catch (JMSException e) {
        log.error("Listen Exception occurred: " + e.toString());
      } finally {
        doCleanup();
      }
    }
  }
示例#29
0
  private int receiveUntilEmpty(Session session, Queue queue) {
    Message message = null;
    int count = 0;
    do {
      try {
        message = receiveMessage(session, queue);
        if (message != null) {
          // JCA queue returns a message of the ObjectMessage type
          Object messageText =
              (message instanceof TextMessage
                  ? ((TextMessage) message).getText()
                  : ((ObjectMessage) message).getObject());
          System.out.println("===== Received message: " + messageText + " =====");
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      count++;
    } while (message != null);

    if (count != 0) {
      try {
        System.out.println(
            "===== Received " + count + " messages from queue " + queue.getQueueName() + " =====");
      } catch (JMSException e) {
        e.printStackTrace();
      }
    }
    return count;
  }
  protected void activate(ComponentContext componentContext) {

    String serverId = clusterTrackingService.getCurrentServerId();

    clusterTrackingServiceImpl = (ClusterTrackingServiceImpl) clusterTrackingService;

    try {
      connection = connFactoryService.getDefaultConnectionFactory().createConnection();
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Topic dest =
          session.createTopic(
              ClusterTrackingService.EVENT_PING_CLUSTER_USER
                  + "/"
                  + EventUtils.safeTopicElement(serverId));
      MessageConsumer consumer = session.createConsumer(dest);
      consumer.setMessageListener(this);
      connection.start();
    } catch (JMSException e) {
      LOGGER.error(e.getMessage(), e);
      if (connection != null) {
        try {
          connection.close();
        } catch (JMSException e1) {
        }
      }
    }
  }