@@ -279,30 +279,48 @@ Once you have written your transport's sender and receiver, you can register you
279
279
transport factory to be able to use it via a DSN in the Symfony application.
280
280
281
281
Create your Transport Factory
282
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~
282
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
283
283
284
284
You need to give FrameworkBundle the opportunity to create your transport from a
285
285
DSN. You will need an transport factory::
286
286
287
- use Symfony\Component\Messenger\Transport\Factory\AdapterFactoryInterface;
287
+ use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
288
+ use Symfony\Component\Messenger\Transport\TransportInterface;
288
289
use Symfony\Component\Messenger\Transport\ReceiverInterface;
289
290
use Symfony\Component\Messenger\Transport\SenderInterface;
290
291
291
292
class YourTransportFactory implements TransportFactoryInterface
292
293
{
293
- public function createReceiver (string $dsn, array $options): ReceiverInterface
294
+ public function createTransport (string $dsn, array $options): TransportInterface
294
295
{
295
- return new YourReceiver (/* ... */);
296
+ return new YourTransport (/* ... */);
296
297
}
297
298
298
- public function createSender (string $dsn, array $options): SenderInterface
299
+ public function supports (string $dsn, array $options): bool
299
300
{
300
- return new YourSender(/* ... */ );
301
+ return 0 === strpos($dsn, 'my-transport://' );
301
302
}
303
+ }
302
304
303
- public function supports(string $dsn, array $options): bool
305
+ The transport object is needs to implements the ``TransportInterface `` (which simply combine
306
+ the ``SenderInterface `` and ``ReceiverInterface ``). It will look
307
+ like this::
308
+
309
+ class YourTransport implements TransportInterface
310
+ {
311
+ public function send($message) : void
304
312
{
305
- return 0 === strpos($dsn, 'my-transport://');
313
+ // ...
314
+ }
315
+
316
+ public function receive(callable $handler) : void
317
+ {
318
+ // ...
319
+ }
320
+
321
+ public function stop() : void
322
+ {
323
+ // ...
306
324
}
307
325
}
308
326
0 commit comments