Guides
...
Getting Started
Amberflo SDKs

Java

9min

Easily integrates with tomcat/spring.

Github repo with Java SDK samples https://github.com/amberflo/metering-java-sample

XML


Batching Records

Amberflo.io libraries are built to support high throughput environments. That means you can safely send hundreds of meter records per second. For example, you can chose to deploy it on a web server that is serving hundreds of requests per second. However, every call does not result in a HTTP request, but is queued in memory instead. Messages are batched and flushed in the background, allowing for much faster operation. The size of batch and rate of flush can be customized. Defaults: The library will flush every 100 messages (configuration parameter: maxBatchSize) or if 0.5 seconds has passed since the last flush (configuration parameter: maxDelayInSec)

What happens if there are just too many messages? If the module detects that it can’t flush faster than it’s receiving messages, it’ll simply stop accepting messages. This allows your program to continually run without ever crashing due to a backed up metering queue. The maximum meters kept in memory is 100,000 (configuration parameter: maxAsyncQueyeSize).

Flush on demand (Blocking call)

You can flush on demand. For example, at the end of your program, you’ll want to flush to make sure there’s nothing left in the queue. Just call the flush method:

MeteringContext.flushAndClose();

Please note: Calling this method will block the calling thread until there are no messages left in the queue. You’ll want to use it as part of your cleanup scripts and avoid using it as part of the request lifecycle.

Using S3

You can use the java SDK to write to S3, and Amberflo will read it from there

1. create a metering client from configuration file

Java


2. create a s3 metering client with with credentials from code

Java


Code examples

Simple ingest meter

Java

Java


Usage example

Java


Create a customer

Java


Configuration example

Java




Updated 31 Jul 2024
Did this page help you?