Package io.github.elimelt.pmqueue
Class QueueFactory
java.lang.Object
io.github.elimelt.pmqueue.QueueFactory
Factory for creating MessageQueue instances with various configurations.
This class is thread-safe.
Example usage:
String filePath = "path/to/queue.dat";
MessageQueue queue = QueueFactory.createQueue(filePath);
Example usage with custom configuration:
String filePath = "path/to/queue.dat";
MessageQueue queue = new QueueFactory.CustomQueueBuilder()
.withFilePath(filePath)
.withDebugEnabled(true)
.withChecksumEnabled(true)
.withMaxFileSize(1024 * 1024 * 1024)
.withDefaultBufferSize(1024 * 1024)
.withMaxBufferSize(8 * 1024 * 1024)
.withBatchThreshold(64)
.build();
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Creates a queue with a custom configuration.static enum
Predefined queue configurations -
Method Summary
Modifier and TypeMethodDescriptionstatic MessageQueue
createDebugQueue
(String filePath) Creates a queue with debug logging enabled.static MessageQueue
createDurableQueue
(String filePath) Creates a queue optimized for durability and reliability.static MessageQueue
createHighThroughputQueue
(String filePath) Creates a queue optimized for high throughput scenarios.static MessageQueue
createLargeMessageQueue
(String filePath) Creates a queue optimized for storing large messages.static MessageQueue
createLowMemoryQueue
(String filePath) Creates a queue optimized for low memory environments.static MessageQueue
createQueue
(String filePath) Default queue configuration suitable for general use.
-
Method Details
-
createQueue
Default queue configuration suitable for general use. Features moderate buffer sizes and checksum verification.- Parameters:
filePath
- the file path for the queue- Returns:
- MessageQueue instance
- Throws:
IOException
- if an I/O error occurs
-
createHighThroughputQueue
Creates a queue optimized for high throughput scenarios. Features larger buffers, batching, and less frequent checksum verification.Configuration:
- Default buffer size: 4MB
- Max buffer size: 16MB
- Batch threshold: 256
- Checksums: Disabled
- Parameters:
filePath
- the file path for the queue- Returns:
- MessageQueue instance
- Throws:
IOException
- if an I/O error occurs
-
createDurableQueue
Creates a queue optimized for durability and reliability. Features smaller buffers, checksum verification, and debug logging.Configuration:
- Default buffer size: 1MB
- Max buffer size: 4MB
- Batch threshold: 32
- Checksums: Enabled
- Debug logging: Enabled
- Parameters:
filePath
- the file path for the queue- Returns:
- MessageQueue instance
- Throws:
IOException
- if an I/O error occurs
-
createLargeMessageQueue
Creates a queue optimized for storing large messages. Features larger buffers and smaller batch sizes.Configuration:
- Default buffer size: 16MB
- Max buffer size: 32MB
- Batch threshold: 16
- Parameters:
filePath
- the file path for the queue- Returns:
- MessageQueue instance
- Throws:
IOException
- if an I/O error occurs
-
createLowMemoryQueue
Creates a queue optimized for low memory environments. Features smaller buffers and batch sizes.Configuration:
- Default buffer size: 256KB
- Max buffer size: 1MB
- Batch threshold: 16
- Parameters:
filePath
- the file path for the queue- Returns:
- MessageQueue instance
- Throws:
IOException
- if an I/O error occurs
-
createDebugQueue
Creates a queue with debug logging enabled. Features checksum verification and debug logging. Note: Debug logging can impact performance.Configuration:
- Default buffer size: 1MB
- Max buffer size: 2MB
- Batch threshold: 32
- Checksums: Enabled
- Debug logging: Enabled
- Parameters:
filePath
- the file path for the queue- Returns:
- MessageQueue instance
- Throws:
IOException
- if an I/O error occurs
-