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 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 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 getSink(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.SINK)) {
      return null;
    }

    return message.getStringProperty(MessagePropertyNames.SINK);
  }
  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 String getComment(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.COMMENT)) {
      return COMMENT_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.COMMENT);
  }
  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 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 getEventCategory(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_CATEGORY)) {
      return EVENT_MODULE_DEF;
    }

    return message.getStringProperty(MessagePropertyNames.EVENT_CATEGORY);
  }
  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 int getEventType(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_TYPE)) {
      return 0;
    }

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

    return message.getLongProperty(MessagePropertyNames.EVENT_GENERATION_DATE);
  }
  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 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 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;
 }
  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 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 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 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);
  }
 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 String getEventProcessEnv(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.EVENT_PROCESS_ENVIRONMENT))
      return EVENT_PROCESS_EVN_DEF;

    return message.getStringProperty(MessagePropertyNames.EVENT_PROCESS_ENVIRONMENT);
  }