- Can I use ActivpikStompBundle in Laravel, or is it only for Symfony 2?
- This bundle is designed for Symfony 2 and won’t work directly in Laravel. Laravel lacks Symfony’s ContainerInterface and config.yml structure, so you’d need to adapt it manually or use a Laravel-compatible STOMP package like `php-stomp` or `symfony/messenger` with a STOMP transport.
- How do I install ActivpikStompBundle in Symfony 2?
- Add the package via Composer with `"activpik/stomp-bundle": "dev-master"`, then configure it in `config.yml` under `activpik_stomp` with your broker connections and producers. Ensure your Symfony 2 app meets the PHP 5.4+ requirement and has a STOMP-compatible broker like ActiveMQ running.
- What’s the sandbox mode, and how do I enable it?
- Sandbox mode prevents actual message delivery to the broker, letting you test configurations without affecting production. Enable it by setting `sandbox: true` in your `config.yml` under `activpik_stomp`. Useful for debugging or CI environments where you don’t want real messages sent.
- Does this bundle support multiple STOMP brokers (e.g., ActiveMQ and RabbitMQ)?
- No, this bundle only works with STOMP-compatible brokers (e.g., ActiveMQ, Artemis). RabbitMQ requires its own AMQP client like `php-amqplib`. Configure multiple connections in `config.yml` under `connections` to switch between brokers, but all must support STOMP 1.0/1.1.
- How do I create and send a message in a Symfony 2 controller?
- Use the message factory to create a message: `$message = $this->get('activpik_stomp_message_factory')->createMessage(['key' => 'value']);`. Then send it via the producer service: `$this->get('activpik_stomp')->send('producer_name', $message)`. Replace `producer_name` with a key defined in your `producers` config.
- Is there a way to handle message acknowledgments or retries?
- This bundle doesn’t include built-in ACK handling or retries. For consumers, you’ll need to implement manual ACK logic in your STOMP client or extend the bundle. For retries, consider wrapping the `send()` call in a custom service with exponential backoff or using a circuit breaker pattern.
- Will this bundle work with Symfony 5/6 or Laravel?
- No, it’s tightly coupled to Symfony 2’s Container and config system. For modern Symfony, use `symfony/messenger` with a STOMP transport. For Laravel, explore packages like `php-stomp` or build a custom service layer around a STOMP client library.
- How do I test message production without a real broker?
- Enable sandbox mode in `config.yml` (`sandbox: true`) to bypass the broker entirely. For unit tests, mock the `activpik_stomp` service to verify message creation, but you’ll still need a real broker for integration tests or production.
- Are there alternatives to this bundle for Laravel or modern Symfony?
- For Laravel, consider `php-stomp` (raw STOMP client) or `symfony/messenger` with the `symfony/stomp-messenger-transport` bridge. For Symfony 5/6, `symfony/messenger` + STOMP transport is the recommended approach, offering better maintainability, retries, and modern DI support.
- Does this bundle support SSL/TLS for secure STOMP connections?
- No, the bundle doesn’t include SSL/TLS configuration. You’ll need to configure your STOMP broker (e.g., ActiveMQ) with SSL and ensure the client library (e.g., `stomp-php`) supports it. Check the underlying STOMP client’s docs for connection options like `ssl://host:port`.