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());
      }
    }
  }
Example #2
0
 /**
  * Constructs a ColumnFamilyUpdater with the provided {@link ColumnFamilyTemplate} and {@link
  * ColumnFactory}. A {@link Mutator} is created internally for this updater.
  *
  * @param template
  * @param columnFactory
  */
 public ColumnFamilyUpdater(ColumnFamilyTemplate<K, N> template, ColumnFactory columnFactory) {
   super(template, columnFactory, template.createMutator());
 }