List of usage examples for com.amazonaws.services.kinesis.model PutRecordResult toString
@Override
public String toString()
From source file:com.zanox.vertx.mods.KinesisMessageProcessor.java
License:Apache License
protected void sendMessageToKinesis(final Message<JsonObject> event) throws KinesisException { if (kinesisAsyncClient == null) { throw new KinesisException("AmazonKinesisAsyncClient is not initialized"); }/* w ww .j a va 2 s . c om*/ if (!isValid(event.body().getString(PAYLOAD))) { logger.error("Invalid message provided."); return; } JsonObject object = event.body(); logger.debug(" --- Got event " + event.toString()); logger.debug(" --- Got body + " + object.toString()); byte[] payload = object.getBinary(PAYLOAD); if (payload == null) { logger.debug(" --- Payload is null, trying to get the payload as String"); payload = object.getString(PAYLOAD).getBytes(); } logger.debug("Binary payload size: " + payload.length); String msgPartitionKey = object.getString(PARTITION_KEY); String requestPartitionKey = msgPartitionKey != null ? msgPartitionKey : partitionKey; PutRecordRequest putRecordRequest = new PutRecordRequest(); putRecordRequest.setStreamName(streamName); putRecordRequest.setPartitionKey(requestPartitionKey); logger.info("Writing to streamName " + streamName + " using partitionkey " + requestPartitionKey); putRecordRequest.setData(ByteBuffer.wrap(payload)); final Context ctx = vertx.currentContext(); kinesisAsyncClient.putRecordAsync(putRecordRequest, new AsyncHandler<PutRecordRequest, PutRecordResult>() { public void onSuccess(PutRecordRequest request, final PutRecordResult recordResult) { ctx.runOnContext(v -> { logger.info("Sent message to Kinesis: " + recordResult.toString()); sendOK(event); }); } public void onError(final java.lang.Exception iexc) { ctx.runOnContext(v -> { logger.error(iexc); sendError(event, "Failed sending message to Kinesis", iexc); }); } }); }