enqueue/null
Null transport for Enqueue/Queue Interop: a no-op queue implementation that doesn’t send messages anywhere. Useful as a mock transport for tests and local development, while keeping the same messaging APIs and configuration style.
enqueue/null package is a mock transport for the Enqueue library, designed for testing and development environments where no actual message broker (e.g., RabbitMQ, Redis, Amazon SQS) is required. It fits architectures where:
Context or Extension interfaces.php-enqueue/enqueue (v9.x+).TransportFactory with NullTransportFactory in Enqueue’s configuration:
$transport = new NullTransportFactory();
$context = new Context([$transport]);
| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Behavioral Misalignment | Null transport discards all messages silently. May cause subtle bugs if developers assume persistence. | Enforce explicit feature flags (e.g., APP_ENV === 'testing') or use mock assertions (e.g., PHPUnit’s expectException). |
| Testing Gaps | No actual broker = no network/timeout testing. | Supplement with integration tests using Dockerized brokers (e.g., rabbitmq:management). |
| Performance Assumptions | Null transport is O(1) but may mislead performance-sensitive logic. | Document in architecture decision records (ADRs) that null transport is not a performance benchmark. |
| Dependency Bloat | Adds ~1MB to composer.json (minimal impact). | Justify inclusion via test coverage metrics or developer productivity gains. |
php-enqueue/laravel-ext for seamless integration).Phase 1: Local Development
TransportFactory in config/enqueue.php (Laravel) or DI container with NullTransportFactory.'extensions' => [
'dsn' => env('QUEUE_CONNECTION', 'null://'),
],
php-enqueue/laravel-ext for Laravel-specific integration.Phase 2: Testing
Message and Consumer classes to verify logic without a broker.redis://localhost) for end-to-end validation.public function test_null_transport_discards_messages()
{
$transport = new NullTransportFactory();
$producer = new Producer($transport->createContext());
$producer->send(new Message('test'));
$this->assertTrue(true); // No assertions needed; messages are discarded.
}
Phase 3: Production Readiness
APP_ENV !== 'production'.if (app()->environment('production') && config('queue.default') === 'null') {
throw new RuntimeException('Null transport is disabled in production.');
}
php-enqueue/laravel-ext (v1.0+).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Accidental Production Use | All messages silently discarded. | Runtime checks + deployment gates (e.g., php-enqueue/laravel-ext hooks). |
| Untested Broker Logic | Retries, dead-letter queues, or TTLs fail silently. | Enforce integration tests with a real broker in CI. |
| Dependency Updates | Enqueue v10.x breaks null transport compatibility. | Pin php-enqueue/enqueue to a stable minor version in composer.json. |
| Developer Misconfiguration | Mixing null transport with real brokers in the same app. | Use environment-specific configs (e.g., config/enqueue.php overrides). |
How can I help you explore Laravel packages today?