Fusio has an event system which helps to build a pub/sub system. This means consumers of your API can subscribe to specific events. Inside your API endpoint you can then trigger such an event. Fusio will then send the payload to each subscriber in the background.
You need to activate the Cronjob feature to enable Fusio to send messages in the background. The event system creates a cronjob which distributes the pending events.
The user needs to send a HTTP POST request to the
/consumer/subscription endpoint with
the following payload to subscribe to an event :
To publish an event, you need to use the dispatcher to create an event. I.e. the following action shows how to dispatch data to the event "my_event" which then sends the provided data JSON encoded to the subscribed endpoints.
class Collection extends ActionAbstract
public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
// dispatch my event
'foo' => 'bar'
Fusio will send the following HTTP POST request to every subscribed endpoint. If the endpoint returns a non successful status code, Fusio will try to resend the message up to 3 times.
POST /callback HTTP/1.1