Exemplo n.º 1
0
  public CommandMessage parser(
      OrderRoutingInstance instance, ProductRoute orderRoute, CommandMessage order)
      throws Exception {
    Exception error = null;

    try {
      // check SMS syntax
      if (order.getChannel().equals("SMS")) {
        smsParser(instance, orderRoute, order);
      }

      if (order.getStatus() != Constants.ORDER_STATUS_DENIED) {
        order.setCause(orderRoute.getKeyword());

        order.setStatus(Constants.ORDER_STATUS_APPROVED);

        SubscriberCampaignImpl.createCampaignEvent(
            order.getUserId(),
            order.getUserName(),
            order.getOrderId(),
            order.getOrderDate(),
            order.getSubscriberId(),
            order.getSubProductId(),
            order.getIsdn(),
            order.getSubscriberType(),
            order.getProductId(),
            order.getServiceAddress(),
            order.getKeyword(),
            order.getCampaignId(),
            order.getSegmentId(),
            null,
            Constants.DEFAULT_ID,
            "",
            Constants.ORDER_STATUS_PENDING);
      }
    } catch (Exception e) {
      error = e;
    }

    if (error != null) {
      order.setStatus(Constants.ORDER_STATUS_DENIED);

      if (error instanceof AppException) {
        order.setCause(error.getMessage());
      } else {
        order.setDescription(error.getMessage());
      }
    }

    if ((error != null) && !(error instanceof AppException)) {
      throw error;
    }

    return order;
  }
Exemplo n.º 2
0
  // //////////////////////////////////////////////////////
  // process session
  // Author : ThangPV
  // Created Date : 16/09/2004
  // //////////////////////////////////////////////////////
  public void doProcessSession() throws Exception {
    try {

      long startIsdn = Long.parseLong(isdn);
      long maxIsdn = startIsdn;
      if (!endIsdn.equals("")) {
        maxIsdn = Long.parseLong(endIsdn);
      }

      if (maxIsdn <= startIsdn) maxIsdn = startIsdn;

      int count = 0;
      long currentIsdn = startIsdn;

      logMonitor("Begin to send message.");

      while (currentIsdn <= maxIsdn && isAvailable()) {
        for (int i = 0; i < batchSize && currentIsdn <= maxIsdn && isAvailable(); i++) {
          CommandMessage order = new CommandMessage();

          order.setChannel(channel);

          if (channel.equals(Constants.CHANNEL_SMS)) {
            order.setProvisioningType("SMSC");
          }

          order.setUserId(0);
          if (deliveryUser.equals("")) order.setUserName("system");
          else order.setUserName(deliveryUser);

          order.setServiceAddress(serviceAddress);
          order.setIsdn(String.valueOf(currentIsdn));
          order.setShipTo(shipTo);
          order.setTimeout(orderTimeout * 1000);

          order.setKeyword(keyword);

          MQConnection connection = null;
          try {
            connection = getMQConnection();
            connection.sendMessage(
                order,
                "",
                0,
                queueWorking,
                orderTimeout * 1000,
                new String[] {"SystemID"},
                new Object[] {new String(order.getUserName())});
          } finally {
            returnMQConnection(connection);
          }

          // if (displayDebug)
          logMonitor(order.toLogString());

          currentIsdn++;
          count++;
        }
        logMonitor("message count: " + count);
        Thread.sleep(timeBetweenLoop);
      }
    } catch (Exception e) {
      throw e;
    }
  }