Integrate the Tinyid Java Client
masterThe Java client is the recommended way to use Tinyid, capable of over 10 million QPS per instance.
- Add Maven Dependency:
Add
tinyid-clientto yourpom.xml. - Configure Client Properties:
Create a file named
tinyid_client.propertiesand place it in your classpath. It must contain thetinyid.serveraddress and yourtinyid.token. - Generate IDs in Code:
Use the
TinyIdclass to callnextId(bizType)for a single ID ornextId(bizType, batchSize)for a list of IDs.
<!-- Maven Dependency -->
<dependency>
<groupId>com.xiaoju.uemc.tinyid</groupId>
<artifactId>tinyid-client</artifactId>
<version>${tinyid.version}</version>
</dependency>
<!-- tinyid_client.properties -->
tinyid.server=localhost:9999
tinyid.token=0f673adf80504e2eaa552f5d791b644c
<!-- Java Usage -->
Long id = TinyId.nextId("test");
List<Long> ids = TinyId.nextId("test", 10);