public static void addAttachment(Message message, Object name, Object value) throws JMSException {
    Hashtable headerTable = null;

    if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) {
      headerTable = new Hashtable();
    } else {
      headerTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE);
    }

    headerTable.put(name, value);

    if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) {
      message.setObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE, headerTable);
    }
  }
  public static void addDataEntry(Message message, Object name, Object value) throws JMSException {
    Hashtable dataTable = null;

    if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) {
      dataTable = new Hashtable();
    } else {
      dataTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.DATA_TABLE);
    }

    dataTable.put(name, value);

    if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) {
      message.setObjectProperty(MessagePropertyNames.DATA_TABLE, dataTable);
    }
  }
  public static String getEventProcessVersion(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_PROCESS_VERSION)) {
      return EVENT_PROCESS_VERSION_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.EVENT_PROCESS_VERSION);
  }
  public static String getEventProcessName(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_PROCESS_NAME)) {
      return EVENT_PROCESS_NAME_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.EVENT_PROCESS_NAME);
  }
  public static String getCompInstName(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.COMP_INST_NAME)) {
      return COMP_INST_NAME_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.COMP_INST_NAME);
  }
  public static String getEventStatus(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_STATUS)) {
      return EVENT_STATUS_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.EVENT_STATUS);
  }
  public static String getWorkFlowInstId(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.WORK_FLOW_INST_ID)) {
      return WORK_FLOW_INST_ID_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.WORK_FLOW_INST_ID);
  }
  public static String getUserDefinedId(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.USER_DEFINED_DOC_ID)) {
      return USER_DEFINED_DOC_ID_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.USER_DEFINED_DOC_ID);
  }
  public static boolean getIsAlert(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.IS_ALERT)) {
      return false;
    }

    return message.getBooleanProperty(MessagePropertyNames.IS_ALERT);
  }
  public static String getDocumentID(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.DOCUMENT_ID)) {
      return DOCUMENT_ID_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.DOCUMENT_ID);
  }
  public static String getPortName(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.PORT_NAME)) {
      return PORT_NAME_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.PORT_NAME);
  }
  public static String getSourceFPSName(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.SOURCE)) {
      return SOURCE_FPS_NAME_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.SOURCE);
  }
  public static long getTotalTime(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.TOTAL_TIME)) {
      return TOTAL_TIME_DEF;
    }

    return message.getLongProperty(MessagePropertyNames.TOTAL_TIME);
  }
  public static int getEventID(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_ID)) {
      return EVENT_ID_DEF;
    }

    return message.getIntProperty(MessagePropertyNames.EVENT_ID);
  }
  public static String getEventDescription(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_DESCRIPTION)) {
      return EVENT_DESCRIPTION_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.EVENT_DESCRIPTION);
  }
  public static String getComment(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.COMMENT)) {
      return COMMENT_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.COMMENT);
  }
  public static String getSink(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.SINK)) {
      return null;
    }

    return message.getStringProperty(MessagePropertyNames.SINK);
  }
  public static long getEventGenerationDate(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_GENERATION_DATE)) {
      return 0L;
    }

    return message.getLongProperty(MessagePropertyNames.EVENT_GENERATION_DATE);
  }
예제 #19
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 static Hashtable getDataTable(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) {
      return DATA_TABLE_DEF;
    }

    return (Hashtable) message.getObjectProperty(MessagePropertyNames.DATA_TABLE);
  }
  public static int getEventType(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_TYPE)) {
      return 0;
    }

    return message.getIntProperty(MessagePropertyNames.EVENT_TYPE);
  }
  public static String getEventCategory(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_CATEGORY)) {
      return EVENT_MODULE_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.EVENT_CATEGORY);
  }
 public static Hashtable getAttachments(Message message) throws JMSException {
   if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) {
     return ATTACHMENT_TABLE_DEF;
   }
   Hashtable attachments = new Hashtable();
   attachments.putAll((Map) message.getObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE));
   return attachments;
 }
  /**
   * Do property exist
   *
   * @param name The name
   * @return The value
   * @throws JMSException Thrown if an error occurs
   */
  @Override
  public boolean propertyExists(final String name) throws JMSException {
    if (ActiveMQRAMessage.trace) {
      ActiveMQRALogger.LOGGER.trace("propertyExists(" + name + ")");
    }

    return message.propertyExists(name);
  }
  public static Object getAttachment(Message message, String name) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) {
      return ATTACHMENT_PROP_DEF;
    }

    Hashtable attachmentTable;
    attachmentTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE);
    return attachmentTable.get(name);
  }
  public static Object getDataEntry(Message message, Object name) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) {
      return DATA_PROP_DEF;
    }

    Hashtable datTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.DATA_TABLE);

    return datTable.get(name);
  }
  public static String getTextData(Message message) throws JMSException {
    if (message instanceof TextMessage) {
      return ((TextMessage) message).getText();
    }

    if (!message.propertyExists(MessagePropertyNames.TEXT_DATA)) {
      return TEXT_DATA_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.TEXT_DATA);
  }
 public static CarryForwardContext getCarryForwardContext(Message message) throws JMSException {
   if (!message.propertyExists(MessagePropertyNames.CARRY_FORWARD_CONTEXT)) {
     return CarryForwardContext.getDefault();
   }
   String carryForwardContextJson =
       message.getStringProperty(MessagePropertyNames.CARRY_FORWARD_CONTEXT);
   if (!StringUtil.isEmpty(carryForwardContextJson)) {
     Genson genson = new Genson();
     CarryForwardContext carryForwardContext =
         genson.deserialize(carryForwardContextJson, CarryForwardContext.class);
     return carryForwardContext;
   }
   return CarryForwardContext.getDefault();
 }
  public static byte[] getBytesData(Message message) throws JMSException {
    if (message instanceof BytesMessage) {
      BytesMessage bytesMessage = (BytesMessage) message;
      byte bytes[] = new byte[(int) bytesMessage.getBodyLength()];
      bytesMessage.readBytes(bytes);
      return bytes;
    }

    if (!message.propertyExists(MessagePropertyNames.BYTES_DATA)) {
      return BYTES_DATA_DEF;
    }

    return (byte[]) message.getObjectProperty(MessagePropertyNames.BYTES_DATA);
  }
예제 #30
0
 public boolean ok(Message msg) throws JMSException {
   boolean res = false;
   if (validateClass(msg)) {
     if (msg.propertyExists(property)) {
       String p = msg.getStringProperty(property);
       try {
         int i = Integer.parseInt(p);
         // log.debug("Received message " + property +"=" +i);
         if (i >= low && i < max) res = true;
       } catch (NumberFormatException ex) {
         throw new JMSException("Property " + property + " was not int: " + p);
       }
     }
   }
   counter++;
   int mod = counter % report;
   if (mod == 0) log.debug("Have received " + counter + " messages");
   return res;
 }