AmiStream
AmiStream is a lightweight, stable, and extensible Java library for working with the Asterisk AMI (Asterisk Manager Interface). It is designed for server-side applications: PBX integrations, call automation, billing, monitoring, and support systems.
Key features
- Connection and authentication to AMI with automatic reconnection.
- Sending commands and receiving events in real time.
- Asynchronous handling of responses and events.
- Support for transaction correlation (action/response).
- Connection pooling and configurable timeouts.
Installation
<dependency>
<groupId>com.siperf</groupId>
<artifactId>amistream</artifactId>
<version>0.8.17</version>
</dependency>
Quick start
import com.siperf.amistream.AmiClient;
import com.siperf.amistream.ActionResponse;
public class Example {
public static void main(String[] args) throws Exception {
AmiClient client = AmiClient.builder()
.host("127.0.0.1")
.port(5038)
.username("admin")
.password("secret")
.build();
client.connect();
ActionResponse resp = client.action("CoreShowChannels").send().get();
System.out.println(resp.getBody());
client.disconnect();
}
}
Configuration & best practices
- Use a separate connection pool for background jobs and for synchronous requests originating from user sessions.
- Enable AMI message logging only in debug mode (messages may contain sensitive data).
- Configure sensible timeouts and reconnection handling, especially for transient network failures.
License
- Licensed under Apache 2.0 — License