Example #1
0
  private void writePayload(String messageKey, byte[] messageBodyBytes)
      throws ActionProcessingException {
    if (configuration.getDataStore().equals(DataStore.CASSANDRA)) {
      ColumnFamilyUpdater<String, String> updater = cfTemplate.createUpdater(messageKey);
      updater.setByteArray("body", messageBodyBytes);
      updater.setLong("timestamp", System.currentTimeMillis());

      try {
        cfTemplate.update(updater);
      } catch (HectorException ex) {
        throw new ActionProcessingException(
            "Got HectorException writing " + "message to data storage: " + ex.getMessage());
      }
    } else if (configuration.getDataStore().equals(DataStore.HBASE)) {
      try {
        // TODO need to write timestamp too?
        messagePersister.writeMessage(messageKey, messageBodyBytes);
      } catch (HBaseException ex) {
        throw new ActionProcessingException(
            "Got HBaseException writing " + "message to data storage: " + ex.getMessage());
      }
    }
  }