fittinq/symfony-exchange

There is no license information available for the latest version (2.0.1) of this package.

2.0.1 2023-12-11 12:00 UTC

This package is auto-updated.

Last update: 2024-05-11 13:24:07 UTC


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

  1. 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);
  1. 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);
  1. The sendToExchange method constructs the request and sends it to the exchange.

Configuration

Environment Variables

AMQ_EXCHANGE_HOST_URL=