protected CommandMessage sendOrder(CommandMessage message, ServiceRequest request) {
    CommandMessage result = null;

    String sessionId = message.getCorrelationID();

    try {
      message.setUserId(0);
      // message.setUserName(request.getUsername());
      message.setChannel(Constants.CHANNEL_WEB);

      // String requestContent = getRequest(sessionId, request);

      message.setRequestValue(ResponseConstants.SESSION_ID, sessionId);
      // message.setRequestValue(ResponseConstants.VALUE, requestContent);

      result = sendOrder(message, sessionId, 30000);
      // result = new CommandMessage();
      // result.setStatus(Constants.ORDER_STATUS_APPROVED);
      // result.setCause(Constants.SUCCESS);
      // Thread.sleep(1200);

    } catch (Exception e) {
      log.error(e);
    }

    if (result != null) {
      if (log.isDebugEnabled()) {
        // log.debug("response: " + result.toString());
      }
    } else {
      log.error("request with sessionId = " + sessionId + " has response is null");
    }

    return result;
  }
Esempio n. 2
0
  public void copyTo(CommandMessage destination) {
    if (destination == null) {
      return;
    }

    destination.setCorrelationID(correlationID);
    destination.setRequestTime(requestTime);
    destination.setResponseTime(responseTime);
    destination.setOrderId(orderId);
    destination.setOrderDate(orderDate);
    destination.setCycleDate(cycleDate);

    destination.setCompanyId(companyId);
    destination.setGroupId(groupId);
    destination.setUserId(userId);
    destination.setUserName(userName);
    destination.setMerchantId(merchantId);
    destination.setAgentId(agentId);

    destination.setSubscriberId(subscriberId);
    destination.setSubPackageId(subPackageId);
    destination.setSubProductId(subProductId);

    destination.setSegmentId(segmentId);
    destination.setCampaignId(campaignId);
    destination.setRankId(rankId);

    destination.setChannel(channel);
    destination.setServiceAddress(serviceAddress);
    destination.setKeyword(keyword);
    destination.setIsdn(isdn);
    destination.setSubscriberType(subscriberType);
    destination.setShipTo(shipTo);
    destination.setNumSMS(numSMS);

    destination.setActionType(actionType);
    destination.setProductId(productId);
    destination.setAssociateProductId(associateProductId);
    destination.setContentCode(contentCode);
    destination.setContentType(contentType);

    destination.setOfferPrice(offerPrice);
    destination.setPrice(price);
    destination.setQuantity(quantity);
    destination.setDiscount(discount);
    destination.setAmount(amount);
    destination.setScore(score);
    destination.setFullOfCharge(fullOfCharge);

    destination.setProvisioningId(provisioningId);
    destination.setProvisioningType(provisioningType);
    destination.setCommandId(commandId);

    destination.setPaid(paid);

    destination.setFullOfCharge(fullOfCharge);
    destination.setRouteId(routeId);
    destination.setCompletedCommands(completedCommands);
    destination.setParameters(parameters);

    destination.setTimeout(timeout);
    destination.setContent(content);
    destination.setChargeMode(chargeMode);
    destination.setDeliveryWapHref(deliveryWapHref);
    destination.setDeliveryWapTitle(deliveryWapTitle);
    destination.setSecretCode(secretCode);
    destination.setSerial(serial);
    destination.setBalanceType(balanceType);
  }
Esempio n. 3
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;
    }
  }