Welcome to the D-Bus Client Java library! This guide provides a structured learning path for developers using the library for the first time, organized by practical importance and usefulness.
Get up and running immediately with basic D-Bus operations.
- What it does: High-performance, asynchronous D-Bus client for Java applications
- Key benefit: Thread-safe blocking operations with sophisticated dual-pipeline architecture
- Use cases: System integration, IPC, desktop applications, IoT device communication
import com.lucimber.dbus.connection.Connection;
import com.lucimber.dbus.netty.NettyConnection;
// Connect to system bus
Connection connection = NettyConnection.newSystemBusConnection();
connection.connect().toCompletableFuture().get();
// Your D-Bus operations here...
connection.close();📖 Detailed Documentation: Quick Start Guide
Learn to send method calls, handle responses, and work with D-Bus messages.
- Method Calls: Send synchronous and asynchronous method calls
- Signal Handling: Subscribe to and process D-Bus signals
- Message Types: Work with method calls, returns, signals, and errors
- Request-Response: Handle method call timeouts and correlation
import com.lucimber.dbus.message.OutboundMethodCall;
import com.lucimber.dbus.type.*;
OutboundMethodCall call = OutboundMethodCall.Builder
.create()
.withSerial(DBusUInt32.valueOf(1))
.withPath(DBusObjectPath.valueOf("/org/freedesktop/DBus"))
.withMember(DBusString.valueOf("ListNames"))
.withDestination(DBusString.valueOf("org.freedesktop.DBus"))
.withInterface(DBusString.valueOf("org.freedesktop.DBus"))
.withReplyExpected(true)
.build();
CompletableFuture<InboundMessage> response = connection.sendRequest(call);📖 Detailed Documentation: Message Operations
Configure connections for different environments and use cases.
- System Bus: For system-level services (requires permissions)
- Session Bus: For user-level applications
- Custom Address: TCP, Unix sockets, custom transports
import com.lucimber.dbus.connection.ConnectionConfig;
ConnectionConfig config = ConnectionConfig.builder()
.withAutoReconnectEnabled(true)
.withHealthCheckEnabled(true)
.withConnectTimeout(Duration.ofSeconds(10))
.withMethodCallTimeout(Duration.ofSeconds(30))
.build();
Connection connection = NettyConnection.newSystemBusConnection(config);📖 Detailed Documentation:
Create custom handlers for processing D-Bus messages in your application logic.
- Inbound Handlers: Process incoming messages (signals, method calls)
- Outbound Handlers: Modify outgoing messages
- Duplex Handlers: Handle both directions
✅ Important: Your handlers run on dedicated thread pools - blocking operations are completely safe!
import com.lucimber.dbus.connection.AbstractInboundHandler;
import com.lucimber.dbus.connection.Context;
public class MyBusinessLogicHandler extends AbstractInboundHandler {
@Override
public void handleInboundMessage(Context ctx, InboundMessage msg) {
// ✅ SAFE - Database calls, REST APIs, file I/O all OK here!
String result = databaseCall(msg); // Blocking operation - totally fine!
ctx.propagateInboundMessage(enrichMessage(msg, result));
}
}
// Add to pipeline
connection.getPipeline().addLast("business-logic", new MyBusinessLogicHandler());📖 Detailed Documentation:
- Essential: Blocking Operations Guide
- Handler Architecture
Integrate with Spring Boot applications using dependency injection and configuration.
@Configuration
public class DBusConfiguration {
@Bean
public Connection dbusConnection() {
return NettyConnection.newSystemBusConnection();
}
}
@Service
public class MyDBusService {
private final Connection dbusConnection;
public MyDBusService(Connection dbusConnection) {
this.dbusConnection = dbusConnection;
setupHandlers();
}
}- Health checks with Actuator
- Metrics with Micrometer
- Configuration properties
- Lifecycle management
📖 Detailed Documentation:
Simplify D-Bus programming with powerful abstractions.
// Define interface with annotations
@DBusInterface("org.freedesktop.DBus")
public interface DBusService {
@DBusMethod("GetId")
String getId();
@DBusMethod("ListNames")
CompletableFuture<String[]> listNames();
}
// Create proxy - no manual message building!
DBusService service = ServiceProxy.create(
connection,
"/org/freedesktop/DBus",
DBusService.class
);
// Use like a regular Java interface
String id = service.getId();Note: ServiceProxy is for simple client request/response scenarios only. For implementing D-Bus services (server-side), use StandardInterfaceHandler instead.
DBusPromise.from(connection.sendRequest(call))
.timeout(Duration.ofSeconds(5))
.mapReturn()
.firstAs(DBusString.class)
.map(DBusString::getDelegate)
.thenAccept(result -> System.out.println("Result: " + result))
.exceptionally(error -> {
System.err.println("Failed: " + error.getMessage());
return null;
});📖 Detailed Documentation: High-Level Abstractions Example
Explore sophisticated features for production applications.
- Exception propagation and handling
- Circuit breakers and retry patterns
- Health monitoring and reconnection
- Graceful degradation
- Connection pooling strategies
- Metrics collection
- Performance tuning
- Memory management
- Project Reactor integration
- RxJava support
- Async/await patterns
- Backpressure handling
📖 Detailed Documentation:
Understand the sophisticated dual-pipeline architecture for advanced use cases.
- Dual-Pipeline System: Public API + Netty transport layers
- RealityCheckpoint: The bridge between pipeline layers (named after the Logistics drum & bass track!)
- Thread Isolation: ApplicationTaskExecutor vs Netty EventLoop
- Event Propagation: How messages flow through the system
- Custom transport implementations
- Advanced handler development
- Performance optimization
- Understanding thread safety guarantees
📖 Detailed Documentation:
Test your D-Bus integration effectively.
- Unit testing with mocks
- Integration testing with containerized D-Bus daemon (single entry point)
- Performance testing
- Memory testing
The library provides a single, reliable entry point for integration testing:
./gradlew integrationTestThis command automatically:
- Sets up a Linux container with D-Bus daemon
- Copies your source code into the container
- Compiles and runs tests with proper SASL authentication
- Copies test results back to your local project structure
- Works consistently on all platforms (Windows, macOS, Linux)
- Connection health checks
- Pipeline introspection
- Thread analysis
- Performance monitoring
📖 Detailed Documentation:
- D-Bus Specification Overview - Understanding the D-Bus protocol
- Examples Collection - Working code samples
- Timeout Configuration - Managing timeouts
- Message Flow Architecture - Traditional view of message processing
- Transport Strategies - Custom transport implementations
- Quick Start (5 min) → Message Operations (15 min) → Configuration (10 min)
- Handler Development (20 min) + Blocking Operations (essential reading!)
- Spring Boot Integration (15 min) if using Spring
- Complete the New Developer path
- Advanced Features (30 min) → Architecture Deep Dive (45 min)
- Testing & Debugging (20 min)
- Error Handling and Performance Monitoring
- Complete all previous paths
- Study all Architecture Documentation in detail
- Review Transport Strategies and Pipeline Architecture
- Understand the RealityCheckpoint bridge pattern
- Start Simple: Begin with basic message operations before diving into advanced features
- Embrace Blocking: Unlike other async libraries, blocking operations are safe and encouraged in handlers
- Use Spring Boot: The integration patterns make enterprise development much easier
- Read Blocking Operations Guide: This is the most important document for handler development
- Understand the Bridge: The RealityCheckpoint class is the key to understanding thread safety
- Common Issues: Check the Error Handling Guide
- Performance: See Integration Patterns for optimization
- Architecture Questions: Start with Pipeline Architecture
- Examples: Browse working examples for your use case
Happy coding with D-Bus! 🚀