本文整理汇总了Java中com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory类的典型用法代码示例。如果您正苦于以下问题:Java IRecordProcessorFactory类的具体用法?Java IRecordProcessorFactory怎么用?Java IRecordProcessorFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRecordProcessorFactory类属于com.amazonaws.services.kinesis.clientlibrary.interfaces包,在下文中一共展示了IRecordProcessorFactory类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startKinesisConsumer
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory; //导入依赖的package包/类
private void startKinesisConsumer() throws Exception {
AWSCredentialsProvider credentialsProvider = new
DefaultAWSCredentialsProviderChain();
String region = "eu-west-1";
logger.info("Starting in Region " + region);
String workerId = InetAddress.getLocalHost().getCanonicalHostName() + ":" + UUID.randomUUID();
KinesisClientLibConfiguration kinesisClientLibConfiguration = new KinesisClientLibConfiguration(
this.getClass().getName(), TestConstants.stream, credentialsProvider, workerId)
.withInitialPositionInStream(InitialPositionInStream.LATEST).withRegionName(region);
IRecordProcessorFactory recordProcessorFactory = new
RecordFactory();
worker = new Worker(recordProcessorFactory,
kinesisClientLibConfiguration);
es = Executors.newSingleThreadExecutor();
es.execute(worker);
}
示例2: KafkaDynamoStreamAdapter
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory; //导入依赖的package包/类
public KafkaDynamoStreamAdapter(String regionName, String srcTable, IRecordProcessorFactory processorFactory) {
sourceTable = srcTable;
credentialsProvider = new DefaultAWSCredentialsProviderChain();
recordProcessorFactory = processorFactory;
adapterClient = new AmazonDynamoDBStreamsAdapterClient(credentialsProvider, new ClientConfiguration());
dynamoDBClient = new AmazonDynamoDBClient(credentialsProvider, new ClientConfiguration());
cloudWatchClient = new AmazonCloudWatchClient(credentialsProvider, new ClientConfiguration());
if ("local".equalsIgnoreCase(regionName)) {
setClientEndpoints(localddbEndpoint);
} else if (regionName != null) {
Region region = Region.getRegion(Regions.fromName(regionName));
adapterClient.setRegion(region);
dynamoDBClient.setRegion(region);
cloudWatchClient.setRegion(region);
}
}
示例3: start
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory; //导入依赖的package包/类
@Override
public void start() {
IRecordProcessorFactory recordProcessorFactory = new RecordProcessorFactory(getChannelProcessor(),
serializer,
backOffTimeInMillis,
numberRetries,
checkpointIntervalMillis);
worker = new Worker(recordProcessorFactory, kinesisClientLibConfiguration);
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
System.out.println("Shutting down Kinesis client thread...");
worker.shutdown();
}
});
try{
worker.run();
}catch (AmazonClientException e) {
logger.error("Can't connect to amazon kinesis", e);
Throwables.propagate(e);
}
}
示例4: run
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory; //导入依赖的package包/类
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;
}
示例5: main
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
java.security.Security.setProperty("networkaddress.cache.ttl" , "60");
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
connector.setPort(80);
server.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setResourceBase(".");
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
ServletHolder holderEvents = new ServletHolder("ws-events", MessageProxyServlet.class);
context.addServlet(holderEvents, "/kinesisapp/*");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, context, new DefaultHandler() });
server.setHandler(handlers);
server.start();
AWSCredentialsProvider credentialsProvider = new EnvironmentVariableCredentialsProvider();
KinesisClientLibConfiguration kinesisConfig = new KinesisClientLibConfiguration(
System.getProperty("kinesisapp.name"),
System.getProperty("kinesisapp.stream"),
credentialsProvider, Long.toString(System.currentTimeMillis()))
.withKinesisEndpoint(System.getProperty("kinesisapp.endpoint"));
IRecordProcessorFactory factory = new Factory();
Worker worker = new Worker(factory, kinesisConfig);
worker.run();
/*
Processor p = new Processor();
p.test();
*/
}
示例6: run
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory; //导入依赖的package包/类
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 AggregatorProcessorFactory(
aggGroup);
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...");
} else {
shutdown();
}
exitCode = 1;
}
}
return exitCode;
}
示例7: main
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory; //导入依赖的package包/类
/**
* @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);
}
示例8: main
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory; //导入依赖的package包/类
/**
* @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 " + TweetamoServer.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 TweetamoRecordProcessorFactory();
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);
}