com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory Java Examples
The following examples show how to use
com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KinesisDataStreamsWorker.java From amazon-kinesis-video-streams-parser-library with Apache License 2.0 | 5 votes |
@Override public void run() { try { String workerId = InetAddress.getLocalHost().getCanonicalHostName() + ":" + UUID.randomUUID(); KinesisClientLibConfiguration kinesisClientLibConfiguration = new KinesisClientLibConfiguration(APPLICATION_NAME, kdsStreamName, credentialsProvider, workerId); kinesisClientLibConfiguration.withInitialPositionInStream(SAMPLE_APPLICATION_INITIAL_POSITION_IN_STREAM) .withRegionName(region.getName()); final IRecordProcessorFactory recordProcessorFactory = () -> new KinesisRecordProcessor(rekognizedFragmentsIndex, credentialsProvider); final Worker worker = new Worker(recordProcessorFactory, kinesisClientLibConfiguration); System.out.printf("Running %s to process stream %s as worker %s...", APPLICATION_NAME, kdsStreamName, workerId); int exitCode = 0; try { worker.run(); } catch (Throwable t) { System.err.println("Caught throwable while processing data."); t.printStackTrace(); exitCode = 1; } System.out.println("Exit code : " + exitCode); } catch (Exception e) { e.printStackTrace(); } }
Example #2
Source File: ManagedConsumer.java From aws-big-data-blog with Apache License 2.0 | 5 votes |
public int run() throws Exception { configure(); System.out.println(String.format("Starting %s", appName)); LOG.info(String.format("Running %s to process stream %s", appName, streamName)); IRecordProcessorFactory recordProcessorFactory = new ManagedClientProcessorFactory( this.templateProcessor); Worker worker = new Worker(recordProcessorFactory, this.config); int exitCode = 0; int failures = 0; // run the worker, tolerating as many failures as is configured while (failures < failuresToTolerate || failuresToTolerate == -1) { try { worker.run(); } catch (Throwable t) { LOG.error("Caught throwable while processing data.", t); failures++; if (failures < failuresToTolerate) { LOG.error("Restarting..."); } exitCode = 1; } } return exitCode; }
Example #3
Source File: KinesisApplication.java From aws-big-data-blog with Apache License 2.0 | 5 votes |
/** * @param args Property file with config overrides (e.g. application name, stream name) * @throws IOException Thrown if we can't read properties from the specified properties file */ public static void main(String[] args) throws IOException { String propertiesFile = null; if (args.length > 1) { System.err.println("Usage: java " + KinesisApplication.class.getName() + " <propertiesFile>"); System.exit(1); } else if (args.length == 1) { propertiesFile = args[0]; } configure(propertiesFile); System.out.println("Starting " + applicationName); LOG.info("Running " + applicationName + " to process stream " + streamName); IRecordProcessorFactory recordProcessorFactory = new KinesisRecordProcessorFactory(redisEndpoint, redisPort); Worker worker = new Worker(recordProcessorFactory, kinesisClientLibConfiguration); int exitCode = 0; try { worker.run(); } catch (Throwable t) { LOG.error("Caught throwable while processing data.", t); exitCode = 1; } System.exit(exitCode); }
Example #4
Source File: KinesisClientLibraryPipelinedRecordProcessorFactory.java From amazon-kinesis-connectors with Apache License 2.0 | 3 votes |
/** * Constructor to wrap an {@link IRecordProcessorFactory} as a pipelined record processor factory. Default values are used for maximum queue wait time and * maximum process records wait time. * * @param factory * The {@link IRecordProcessorFactory} to wrap * @param maxQueueSize * The maximum number of records to retrieve and buffer in memory */ public KinesisClientLibraryPipelinedRecordProcessorFactory(IRecordProcessorFactory factory, int maxQueueSize) { this.recordProcessorFactory = factory; this.maxQueueSize = maxQueueSize; this.maxQueueWaitTimeMs = null; this.maxProcessRecordsWaitTimeMs = null; }
Example #5
Source File: KinesisClientLibraryPipelinedRecordProcessorFactory.java From amazon-kinesis-connectors with Apache License 2.0 | 3 votes |
/** * Constructor to wrap an {@link IRecordProcessorFactory} as a pipelined record processor factory. If null values are passed for maxQueueWaitTimeMs or * maxProcessRecordsWaitTimeMs, default values are used. * * @param factory * The {@link IRecordProcessorFactory} to wrap * @param maxQueueSize * The maximum number of records to retrieve and buffer in memory * @param maxQueueWaitTimeMs * Maximum time to block on the queue waiting for GetRecords result in milliseconds * @param maxProcessRecordsWaitTimeMs * Maximum time to wait for the queue consumer to shutdown (finish ProcessRecords call) in milliseconds */ public KinesisClientLibraryPipelinedRecordProcessorFactory(IRecordProcessorFactory factory, int maxQueueSize, Long maxQueueWaitTimeMs, Long maxProcessRecordsWaitTimeMs) { this.recordProcessorFactory = factory; this.maxQueueSize = maxQueueSize; this.maxQueueWaitTimeMs = maxQueueWaitTimeMs; this.maxProcessRecordsWaitTimeMs = maxProcessRecordsWaitTimeMs; }