This is core bundle for idempotent consumer. It provides basic functionality to make your consumer idempotent.
Add this package to your project
composer require mrandmrssmith/idempotent-consumer-bundle- Structure:
Persistance- Provide interfaces for persistanceResolver- Interface which should be use to retrive idempotent key from message and register of these resolversChecker- main service which will handle idempotent logic on message entry you should use this checker before message processing and based on result of check you should decide to process message or notFinalizer- main service which will handle idempotent logic on message exit you should use this finalizer after message processing to mark message as processed or when message failed.
- Implement
Persistanceinterface- you can implement you own persistence by implement these interfaces and register them in services.
- there is one ready persistence provided by
mrandmrssmith/idempotent-consumer-doctrine-persistence-bundlewhich provide persistence layer using doctrine
- Resolvers:
- you have to implement key resolvers for your consumers.
- it works as strategy pattern. You have to register your resolver and add tag
idempotent.key_resolver
- Checker and Finalizer
- you have to use these services with your consumer checker on entry of message and finalizer after message processing
- you can use package for symfony messenger
mrandmrssmith/idempotent-symfony-messenger-consumer-bundle
- Settings
- By default failed messages which have status failed are skipped but it may be possible that you may want to try handle again message with status failed so there are 2 options for this
- first option is in your configuration for this bundle set
process_failed_messagesto true
that will change default value (false) ofmms_idempotent_consumer: process_failed_messages: true
$wantToProcessFailedMessageinDefaultProcessFailedMessageVoterto value which you set here- second option is implement own voter - that may be solution when you want to implement own logic which tell if we should handle this message again or not for that you should
you can replace default voter to your own implementation ofmms_idempotent_consumer: custom_process_failed_messages_voter: id_of_your_voter_service
ProcessFailedMessageVoterwhat's provide you full control over processing failed messages.
Dockerfile added for testing of local build...
To build the image see the Makefile for all available commands.
make build74To run a composer install use;
make composer-installTo run them.
Run composer install first as above.
make tests-php7https://github.com/PHPCompatibility/PHPCompatibility
Run composer install first as above.
make phpcompat-74-srcmake phpcompat-74-vendor