To my blog-samples project I've added a Splash Events client using Spring Security's OAuth2 client support. Out of the box, it contains APIs for querying events, event extra details, event attendees, and contacts (attendees for one or more events), see its integrated tests for examples on how this client can be used. Although written in Kotlin, it should work fine integrated with any JVM-compatible language, I use it with a Java application.
One peculiarity with Splash Events is the API returning a 200 with a 429 internal error code when too many requests are being made, requiring some delay (usually a second will do) before making another request. I believe the limitation for at least my project is no more than two calls per second allowed, something that can easily occur when querying for many contacts or events. For optimal performance, for areas of the code where you're rapidly querying Splash, it's good to install an adjustable wait-state prior to making the call, to avoid the delays with receiving the 429 and making another call thereafter. Choose the smallest wait state that doesn't result in excessive 429 messages. Further, of course, code calling the client should still handle the case of a 429 getting returned, pausing, and making the same request again. For my calls to get contact data, I use code similar to the following:
private Contact getContact(String contactId) { do { try { insertDelay(); // Thread.sleep(xxx) etc. return splashQueryRunner.getContact(contactId).getData(); } catch (ServiceException exception) { int statusCode = exception.getStatusCode(); if (statusCode == 429) { pauseDueToTooManyRequests(); // Thread.sleep(xxx) with different logging } else { // something else logger.error("getContact API Call Service Exception: code = {}, message = {}", statusCode, exception.getMessage()); throw exception; } } catch (Exception exception) { logger.error("Splash API getContact event call returned error", exception); throw exception; } } while (true); }
Posted by Glen Mazza in Programming at 07:00AM May 27, 2024 | Comments[0]