fittinq / symfony-exchange
There is no license information available for the latest version (3.1.0) of this package.
3.1.0
2024-09-02 13:29 UTC
Requires
Requires (Dev)
- fittinq/symfony-mock: ^4.4
- phpunit/phpunit: ^9.5
- symfony/yaml: ^6.1
README
Introduction
The Sender
class is responsible for sending messages to the amq-exchange service using the Symfony HttpClient.
It facilitates communication with the exchange service, allowing you to send messages to amq-exchange
Table of contents
Installation
composer require fittinq/symfony-exchange
Usage
- Create an instance of the Sender class, providing it with the required dependencies: HttpClientInterface, TokenService, and the exchange URL.
use Fittinq\Symfony\Exchange\Sender;
use Fittinq\Symfony\Authenticator\TokenService\TokenService;
use Symfony\Contracts\HttpClient\HttpClientInterface;
$httpClient = new HttpClient(); // Replace with your actual HttpClient instance.
$tokenService = new TokenService(); // Replace with your TokenService instance.
$exchangeUrl = 'https://exchange-service-url'; // Replace with the actual exchange service URL.
$sender = new Sender($httpClient, $tokenService, $exchangeUrl);
- Use the sendToExchange method to send a message to the exchange service. Provide it with a stdClass object, a source, event, and an optional target.
$message = new stdClass();
$message->content = 'This is the message content';
$source = 'source';
$event = 'event';
$target = 'optional-target'; // You can omit this if not needed.
$sender->sendToExchange($message, $source, $event, $target);
- The sendToExchange method constructs the request and sends it to the exchange.
Configuration
Environment Variables
AMQ_EXCHANGE_HOST_URL=