Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Pubsub Queue Laravel Package

kainxspirits/laravel-pubsub-queue

Laravel queue driver for Google Cloud Pub/Sub. Configure a pubsub connection with project, queue/topic naming, retries and timeouts, and optional auto-creation of topics/subscriptions. Ideal for running Laravel jobs over Pub/Sub with minimal setup.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel 12 Compatibility: Now officially supports Laravel 12, aligning with the latest LTS release and ensuring long-term viability for new Laravel projects. This reduces technical debt for teams adopting Laravel 12 early.
  • Pub/Sub Alignment: Retains full compatibility with Google Cloud Pub/Sub’s event-driven model, ideal for decoupled architectures (e.g., microservices, real-time processing).
  • Decoupling: Continues to enable seamless separation of job processing from application logic, critical for scalability and fault isolation.
  • Event-Driven Workflows: Supports complex workflows (e.g., fan-out patterns, event sourcing) with minimal overhead.

Integration Feasibility

  • Laravel 12 Support: No breaking changes for core functionality; existing Laravel 10/11 integrations remain intact. Teams can upgrade incrementally.
  • Push Subscription Fix: PR #81 resolves a critical issue with afterCommit() in push subscriptions, improving reliability for synchronous job processing (e.g., webhooks, immediate acknowledgments).
  • Google Cloud SDK Dependency: Still requires google/cloud-pubsub (v1.30.0+ recommended), but no version conflicts introduced in this release.
  • Configuration Overhead: Minimal changes needed for Laravel 12 migrations (e.g., updated service provider bootstrapping). See updated README for Laravel 12-specific setup.

Technical Risk

  • Laravel 12 Migration:
    • Risk: Potential undocumented changes in Laravel 12’s queue system (e.g., container binding, event dispatching).
    • Mitigation: Test with Laravel’s queue:work and dispatch() in a staging environment. Monitor for deprecated methods (e.g., Illuminate\Queue\Jobs\Job).
  • Push Subscription Reliability:
    • Risk: The afterCommit() fix (PR #81) may introduce edge cases for transactions or long-running jobs.
    • Mitigation: Validate in staging with mixed push/pull subscriptions. Use pull subscriptions for critical paths if stability is a concern.
  • Dependency Updates:
    • Risk: Underlying google/cloud-pubsub or Laravel dependencies may introduce breaking changes.
    • Mitigation: Pin versions in composer.json until stability is confirmed:
      "require": {
          "google/cloud-pubsub": "^1.30.0",
          "kainxspirits/laravel-pubsub-queue": "^0.10.0"
      }
      

Key Questions

  1. Laravel 12 Readiness:
    • Are you already on Laravel 12, or does this package enable a smoother migration path?
    • Have you tested the package with Laravel 12’s new features (e.g., app contexts, improved testing)?
  2. Push vs. Pull Strategy:
    • Will you leverage the fixed afterCommit() for push subscriptions, or stick to pull for reliability?
    • How will you handle push subscription timeouts (e.g., 10–60s limits)?
  3. Transaction Behavior:
    • Are your jobs transactional? The push fix may affect rollback scenarios.
  4. Contributor Activity:
    • The new contributors (@andreladocruz, @toshitsuna-otsuka) suggest growing community support. Will this impact your long-term support strategy?
  5. Deprecation Timeline:
    • Laravel 10/11 support may end soon. Plan for a phased upgrade if using older Laravel versions.

Integration Approach

Stack Fit

  • Laravel 12:
    • Updated service provider and queue driver registration for Laravel 12’s container changes.
    • Example configuration (Laravel 12):
      // config/queue.php
      'connections' => [
          'pubsub' => [
              'driver' => 'pubsub',
              'project_id' => env('GOOGLE_CLOUD_PROJECT'),
              'topic' => env('PUBSUB_TOPIC'),
              'subscription' => env('PUBSUB_SUBSCRIPTION'),
              'key_file' => env('GOOGLE_APPLICATION_CREDENTIALS'),
              'push_endpoint' => env('PUBSUB_PUSH_ENDPOINT'), // For push subscriptions
          ],
      ],
      
  • Push Subscription Workflow:
    • Fixed afterCommit() ensures push subscriptions work reliably with Laravel’s queue system. Use case:
      // Dispatch a job to a push subscription
      PubSubJob::dispatch()->onQueue('pubsub-push');
      
    • Worker Setup: Deploy a long-running HTTP endpoint (e.g., Laravel Horizon or a dedicated server) to handle push deliveries.
  • Google Cloud SDK:
    • Ensure google/cloud-pubsub is updated (composer require google/cloud-pubsub:^1.30.0).

Migration Path

  1. Phase 1: Laravel 12 Compatibility Test
    • Upgrade Laravel to 12 in a staging environment.
    • Test the package with existing jobs and push/pull subscriptions.
    • Verify no regressions in job serialization/deserialization.
  2. Phase 2: Push Subscription Validation
    • If using push subscriptions, test the afterCommit() fix with:
      • Transactional jobs (e.g., database + Pub/Sub).
      • Long-running jobs (monitor timeout behavior).
    • Fallback to pull subscriptions if push stability is unclear.
  3. Phase 3: Full Rollout
    • Update composer.json to pin the new version.
    • Deploy workers with Laravel 12’s queue system:
      php artisan queue:work pubsub-push --tries=3 --timeout=120
      

Compatibility

  • Laravel Versions:
    • Supported: Laravel 12 (primary), 10/11 (legacy).
    • Deprecation Risk: Laravel 10/11 support may be dropped in future releases. Plan to upgrade.
  • Pub/Sub Features:
    • Push subscriptions now work with afterCommit() (PR #81). Test with:
      • ackDeadlineSeconds (default: 10s).
      • Idempotent job handling (duplicates may occur during retries).
    • Pull subscriptions remain unchanged; preferred for reliability.
  • Job Serialization:
    • Laravel 12’s improved serialization (e.g., for closures) may require job class updates. Test with:
      use Illuminate\Bus\Queueable;
      use Kainxspirits\PubSubQueue\Jobs\PubSubJob;
      
      class MyJob extends PubSubJob {
          use Queueable;
          // ...
      }
      

Sequencing

  1. Infrastructure:
    • For push subscriptions, deploy an HTTPS endpoint (e.g., /pubsub-push) to receive Pub/Sub messages.
    • Example (Laravel route):
      Route::post('/pubsub-push', [PubSubPushHandler::class, 'handle']);
      
  2. Configuration:
    • Update config/queue.php and .env for Laravel 12:
      GOOGLE_CLOUD_PROJECT=your-project
      PUBSUB_TOPIC=your-topic
      PUBSUB_SUBSCRIPTION=your-subscription
      PUBSUB_PUSH_ENDPOINT=https://your-app.com/pubsub-push
      
  3. Worker Deployment:
    • Use Laravel’s queue:work with explicit queue binding:
      # Pull subscription
      php artisan queue:work --queue=pubsub
      
      # Push subscription (long-running)
      php artisan queue:work --queue=pubsub-push --daemon
      
  4. Monitoring:
    • Add Cloud Monitoring for push endpoint latency and Pub/Sub backlog:
      • Metric: pubsub.googleapis.com/subscription/backlog_messages.
      • Alert on high subscription/oldest_unacked_message_age.

Operational Impact

Maintenance

  • Dependency Management:
    • Pin google/cloud-pubsub and kainxspirits/laravel-pubsub-queue to specific versions until stability is confirmed:
      "require": {
          "google/cloud-pubsub": "1.30.0",
          "kainxspirits/laravel-pubsub-queue": "0.10.0"
      }
      
    • Monitor for Laravel 12-specific bug fixes in the package.
  • Configuration:
    • Centralize Pub/Sub settings in Laravel’s config or a secrets manager (e.g., Google Secret Manager).
    • Document push subscription endpoints and their IAM requirements.
  • Documentation:
    • Update runbooks for:
      • Push subscription timeouts (e.g., "If the endpoint takes >10s to respond, the message is redelivered").
      • Laravel 12-specific queue commands (e.g., queue:flush behavior).

Support

  • Troubleshooting:
    • Push Subscription Issues:
      • Symptom: Messages not delivered to the endpoint.
      • **Debug Steps
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky