Java SDK¶
Zero-dependency Java client for PulseRoute. Requires Java 11+.
Installation¶
Maven¶
<dependency>
<groupId>dev.pulseroute</groupId>
<artifactId>pulseroute-sdk</artifactId>
<version>0.1.0</version>
</dependency>
Gradle¶
Quick Start¶
PulseRouteClient pulse = PulseRouteClient.builder()
.apiKey(System.getenv("PULSEROUTE_KEY"))
.baseUrl("https://api.pulseroute.dev")
.build();
// Pre-transaction: get routing decision
RouteResponse route = pulse.getRoute(new RouteRequest("US", "USD", "visa"));
// Process payment with route.getProcessorId()...
// Post-transaction: report outcome (fire-and-forget)
pulse.reportOutcome(new OutcomeRequest(
route.getRuleId(), route.getProcessorId(), true, 145.0
));
Stripe + Adyen Integration¶
public PaymentResult processPayment(String country, String currency,
String cardType, long amountCents) {
RouteResponse route = pulse.getRoute(new RouteRequest(country, currency, cardType));
long start = System.currentTimeMillis();
try {
PaymentResult result;
if ("stripe".equals(route.getProcessorId())) {
result = stripe.charges().create(amountCents, currency);
} else {
result = adyen.payments().create(amountCents, currency);
}
long latency = System.currentTimeMillis() - start;
pulse.reportOutcome(new OutcomeRequest(
route.getRuleId(), route.getProcessorId(), true, latency
));
return result;
} catch (PaymentException e) {
long latency = System.currentTimeMillis() - start;
pulse.reportOutcome(new OutcomeRequest(
route.getRuleId(), route.getProcessorId(), false, latency, e.getCode()
));
throw e;
}
}
Spring Boot¶
@Configuration
public class PulseRouteConfig {
@Bean
public PulseRouteClient pulseRouteClient(
@Value("${pulseroute.api-key}") String apiKey,
@Value("${pulseroute.base-url:http://localhost:8080}") String baseUrl) {
return PulseRouteClient.builder()
.apiKey(apiKey)
.baseUrl(baseUrl)
.build();
}
}
Configuration¶
| Option | Default | Description |
|---|---|---|
apiKey |
(none) | API key for authentication |
baseUrl |
http://localhost:8080 |
PulseRoute API URL |
timeoutMs |
5000 | HTTP request timeout |
flushIntervalMs |
5000 | Outcome flush interval |
batchSize |
50 | Max outcomes per flush |
Features¶
- Zero dependencies — Java 11+
java.net.http.HttpClient - Local decision cache — returns cached decision if API unreachable
- Fire-and-forget outcomes — buffered and flushed asynchronously
- Thread-safe — safe to share as singleton
- AutoCloseable — use with try-with-resources