Search in sources :

Example 1 with AmazonKinesisFirehose

use of com.amazonaws.services.kinesisfirehose.AmazonKinesisFirehose in project aws-ingesting-click-logs-using-terraform by aws-samples.

the class ClickLoggerHandler method updateClickLogRequestToStream.

private Boolean updateClickLogRequestToStream(ClickLogRequest clickLogRequest) {
    System.out.println("Inside updateClickLogRequestToStream method for the input");
    try {
        AmazonKinesisFirehose amazonKinesisFirehoseClient = AmazonKinesisFirehoseClientBuilder.standard().withRegion(region).build();
        PutRecordRequest putRecordRequest = new PutRecordRequest();
        putRecordRequest.setDeliveryStreamName(stream_name);
        Gson gson = new Gson();
        String messageJson = gson.toJson(clickLogRequest);
        System.out.println("gson - " + messageJson);
        Record record = new Record().withData(ByteBuffer.wrap(messageJson.toString().getBytes()));
        putRecordRequest.setRecord(record);
        PutRecordResult putRecordResult = amazonKinesisFirehoseClient.putRecord(putRecordRequest);
        System.out.println("updated the stream for recordid - " + putRecordResult.getRecordId());
        return true;
    } catch (Exception e) {
        System.out.println("Error occurred - " + e.getMessage());
    }
    return false;
}
Also used : PutRecordResult(com.amazonaws.services.kinesisfirehose.model.PutRecordResult) PutRecordRequest(com.amazonaws.services.kinesisfirehose.model.PutRecordRequest) Gson(com.google.gson.Gson) Record(com.amazonaws.services.kinesisfirehose.model.Record) AmazonKinesisFirehose(com.amazonaws.services.kinesisfirehose.AmazonKinesisFirehose)

Example 2 with AmazonKinesisFirehose

use of com.amazonaws.services.kinesisfirehose.AmazonKinesisFirehose in project camel by apache.

the class KinesisFirehoseComponentIntegrationTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    AmazonKinesisFirehose client = AmazonKinesisFirehoseAsyncClientBuilder.defaultClient();
    JndiRegistry registry = super.createRegistry();
    registry.bind("FirehoseClient", client);
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) AmazonKinesisFirehose(com.amazonaws.services.kinesisfirehose.AmazonKinesisFirehose)

Aggregations

AmazonKinesisFirehose (com.amazonaws.services.kinesisfirehose.AmazonKinesisFirehose)2 PutRecordRequest (com.amazonaws.services.kinesisfirehose.model.PutRecordRequest)1 PutRecordResult (com.amazonaws.services.kinesisfirehose.model.PutRecordResult)1 Record (com.amazonaws.services.kinesisfirehose.model.Record)1 Gson (com.google.gson.Gson)1 JndiRegistry (org.apache.camel.impl.JndiRegistry)1