Lightning is a Java based, super fast, multi-mode, asynchronous, and distributed URL execution engine from eBay that delivers at scale.
Please refer Detailed documentation for more information.
To configure lightning core as an embedded service within the application. Click to Learn more about different Modes of Operation.
// Build LightningClient in Embedded Mode
final LightningClient client = new LightningClientBuilder().setEmbeddedMode(true).build();
// Create task List
final List<Task> lightningTasks = new ArrayList<>();
lightningTasks.add(new URLTask("http://www.ebay.com"));
lightningTasks.add(new URLTask("http://www.stubhub.com"));
lightningTasks.add(new URLTask("http://github.com/"));
// Submit task List with LightningResponseCallback and Timeout
final LightningResponseCallback callback = new LightningResponseCallback() {
// Called when request could not complete within the given timeout
@Override
public void onTimeout(LightningResponse response) {
System.out.println("Lightning request timed out.");
}
// Called when the request execution is completed
@Override
public void onComplete(LightningResponse response) {
System.out.println("Request execution complete.");
final int failureCount = response.getFailedResponses().size();
if (failureCount > 0) {
System.out.println("One or more requests failed.");
} else {
System.out.println("All results are successful with HTTP 200.");
// Consume response...
}
System.out.println(response.prettyPrint());
}
};
client.submitWithCallback(lightningTasks, callback, 5000);
Please find step-by-step here.
To configure lightning core as an external service.
//Build LightningClient and register with a core instance running @localhost on port 8989
LightningClient client = new LightningClientBuilder().addSeed("localhost").setCorePort(8989).build();
//Create tasks List
final List<Task> lightningTasks = new ArrayList<Task>();
lightningTasks.add(new URLTask("http://www.ebay.com"));
lightningTasks.add(new URLTask("http://www.stubhub.com"));
lightningTasks.add(new URLTask("http://github.com/"));
//Submit task List with LightningResponseCallback and Timeout
LightningResponseCallback callback = new LightningResponseCallback() {
// Called when request could not complete within the given timeout
@Override
public void onTimeout(LightningResponse response) {
log.info("Lightning request timed out.");
}
//Called when the request execution is completed
@Override
public void onComplete(LightningResponse response) {
log.info("Request execution complete.");
int failureCount = response.getFailedResponses().size();
if (failureCount > 0) {
log.info("One or more requests failed.");
} else {
log.info("All results are successful with HTTP 200.");
//Consume response...
}
log.info(response.prettyPrint());
}
};
client.submitWithCallback(tasks, callback, 5000);
Please find step-by-step here.
See CHANGELOG.md
Lightning is served to you by Shankar Shukla and Site Engineering Tools Team(Ananth, Prabhu Pandurangan, Pragadesh) at eBay Inc. We would like to give special thanks to our Director Sham Kalwit for his vision, valuable guidance and encouragement.
MIT