- How do I integrate enqueue/gps with a Laravel application that already uses Enqueue?
- First, ensure you have `enqueue/laravel` installed via Composer. Then, configure your queue connection in `config/queue.php` to use the `gps` transport. The package leverages Enqueue’s abstraction, so existing Laravel queue workers (e.g., `php artisan queue:work`) will work seamlessly with GCP Pub/Sub. Verify your GCP service account credentials are set in the Enqueue configuration.
- Can I use enqueue/gps without Enqueue in a Laravel project?
- No, this package requires Enqueue as a dependency. If you’re not already using Enqueue, you’ll need to install it alongside `enqueue/gps`. This adds ~10MB to your project and may introduce complexity if you’re relying on Laravel’s native queue system. Consider alternatives like `google/cloud-pubsub` if Enqueue isn’t a priority.
- What Laravel versions does enqueue/gps support?
- The package works with Laravel 8+ and requires PHP 8.0+ (though PHP 7.4+ is officially supported). Ensure your Laravel version aligns with Enqueue’s compatibility matrix, as Enqueue itself may have version-specific requirements. Test thoroughly, especially if using older Laravel versions, as some features may rely on newer PHP improvements.
- How do I handle message serialization for complex Laravel payloads?
- By default, `enqueue/gps` uses JSON serialization. For Laravel-specific payloads (e.g., Eloquent models, closures), you’ll need to implement custom serialization logic. Use Enqueue’s `Serializer` interface or Laravel’s `serialize()` helper, but ensure the deserialized data matches your queue job’s expectations. Test edge cases like nested objects or circular references.
- Does enqueue/gps support dead-letter queues (DLQ) for failed messages?
- No, the package doesn’t include built-in DLQ support. You’ll need to configure a custom dead-letter topic in GCP Pub/Sub and handle failed messages via Enqueue’s `RetryStrategy` or by subscribing to the DLQ topic separately. Monitor failed messages using GCP’s Pub/Sub metrics or integrate with tools like Enqueue Horizon for visibility.
- How do I manage GCP Pub/Sub topics and subscriptions dynamically with this package?
- The package supports dynamic topic/subscription creation via its `Transport` class methods (`createTopic()`, `createSubscription()`). However, you’ll need to handle IAM permissions and quota limits manually. For production, consider using Terraform or GCP’s Cloud Console to pre-provision resources, then use the package for runtime management. Avoid dynamic creation in high-throughput environments to prevent throttling.
- What are the performance implications of using GCP Pub/Sub with Laravel?
- GCP Pub/Sub is highly scalable but may introduce latency on cold starts (first invocation of a consumer). Mitigate this with persistent connections or pre-warmed workers. Message ordering is per-partition, so design your system to tolerate reordering if needed. For high-volume workloads, monitor GCP’s Pub/Sub quotas and consider batching messages to reduce API calls.
- How does enqueue/gps compare to the native `google/cloud-pubsub` PHP client for Laravel?
- `google/cloud-pubsub` is a lower-level SDK, while `enqueue/gps` provides a Queue Interop-compliant abstraction, making it easier to integrate with Laravel’s queue system if you’re already using Enqueue. The latter offers better compatibility with Laravel’s queue workers and Enqueue’s ecosystem (e.g., Horizon). However, `google/cloud-pubsub` gives you finer control over GCP-specific features like push endpoints or exact delivery times.
- Can I use enqueue/gps in a hybrid cloud setup (e.g., GCP + AWS SQS)?
- Yes, but you’ll need to manage multiple queue transports. Configure separate Enqueue connections for each cloud provider (e.g., `gps` for GCP and `aws` for SQS) and route messages accordingly. Use Laravel’s queue failover logic or a service like Enqueue’s `FailoverStrategy` to handle provider-specific failures. Test cross-cloud failover scenarios rigorously.
- What maintenance or monitoring considerations are there for enqueue/gps in production?
- Monitor GCP Pub/Sub metrics (e.g., publish/consumer lag, backlog) via Cloud Monitoring or third-party tools like Datadog. Set up alerts for high backlog or failed deliveries. Regularly audit IAM permissions and service account keys for security. For critical workloads, implement circuit breakers or local queue fallbacks (e.g., Redis) to handle GCP outages gracefully.