<commit_before># ConnectHolland Rabbit MQ Message Enrich Bundle

## Installation

```
composer require connectholland/rabbit-mq-message-enrich-bundle dev-master
```

Do no add the bundle to your AppKernel, there is no bundle class (required).

## Configuration

* Configure producer(s) to put messages on the queue as documented at: https://github.com/php-amqplib/RabbitMqBundle
* Configure consumers to listen for messages as documented at: https://github.com/php-amqplib/RabbitMqBundle
* Configure the service for the consumer to be of type ```ConnectHolland\RabbitMQMessageEnrichBundle\Consumer\EnrichMessageConsumer```
* Configure the JMS serializer to be able to serialize the object you enrich with: https://github.com/schmittjoh/serializer

Example to enrich messages with a ```user_id``` with the information from ```FoobarBundle:User``` in ```user``` listening and publishing on a channel ```foo``` for messages with routing_key ```bar```.

config.yml

``` yml
old_sound_rabbit_mq:
    connections:
        default:
            ...
    consumers:
        enrich_message:
            connection:       default
            exchange_options: {name: 'foo', type: direct, durable: false}
            queue_options:    {name: '', durable: false, auto_delete: true, exclusive: true, routing_keys:  ['bar']}
            callback:         foobar_consumer
    producers:
        foobar_producer:
            exchange_options: {name: 'foo', type: direct, durable: false}
            queue_options: {name: '', durable: false, auto_delete: true, exclusive: true}
```

services.yml
``` yml
services:
    userController:
        class: ConnectHolland\RabbitMQMessageEnrichBundle\Controller\DoctrineEnrichController
        arguments: ["@doctrine", "FoobarBundle:User"]
    foobar_consumer:
        class: ConnectHolland\RabbitMQMessageEnrichBundle\Consumer\EnrichMessageConsumer
        arguments: ["@userController", "@old_sound_rabbit_mq.foobar_producer_producer", "@jsm_serializer", "user_id", "user"]
```

Enitity.User.yml
``` yml
FoobarBundle\Entity\User:
    exclusion_policy: ALL
    properties:
        id:
            expose: true
        user_id:
            expose: true
        email:
            expose: true
        firstName:
            expose: true
        middleName:
            expose: true
        lastName:
            expose: true

```
<commit_msg>Fixed typo in service id<commit_after># ConnectHolland Rabbit MQ Message Enrich Bundle

## Installation

```
composer require connectholland/rabbit-mq-message-enrich-bundle dev-master
```

Do no add the bundle to your AppKernel, there is no bundle class (required).

## Configuration

* Configure producer(s) to put messages on the queue as documented at: https://github.com/php-amqplib/RabbitMqBundle
* Configure consumers to listen for messages as documented at: https://github.com/php-amqplib/RabbitMqBundle
* Configure the service for the consumer to be of type ```ConnectHolland\RabbitMQMessageEnrichBundle\Consumer\EnrichMessageConsumer```
* Configure the JMS serializer to be able to serialize the object you enrich with: https://github.com/schmittjoh/serializer

Example to enrich messages with a ```user_id``` with the information from ```FoobarBundle:User``` in ```user``` listening and publishing on a channel ```foo``` for messages with routing_key ```bar```.

config.yml

``` yml
old_sound_rabbit_mq:
    connections:
        default:
            ...
    consumers:
        enrich_message:
            connection:       default
            exchange_options: {name: 'foo', type: direct, durable: false}
            queue_options:    {name: '', durable: false, auto_delete: true, exclusive: true, routing_keys:  ['bar']}
            callback:         foobar_consumer
    producers:
        foobar_producer:
            exchange_options: {name: 'foo', type: direct, durable: false}
            queue_options: {name: '', durable: false, auto_delete: true, exclusive: true}
```

services.yml
``` yml
services:
    userController:
        class: ConnectHolland\RabbitMQMessageEnrichBundle\Controller\DoctrineEnrichController
        arguments: ["@doctrine", "FoobarBundle:User"]
    foobar_consumer:
        class: ConnectHolland\RabbitMQMessageEnrichBundle\Consumer\EnrichMessageConsumer
        arguments: ["@userController", "@old_sound_rabbit_mq.foobar_producer_producer", "@jms_serializer", "user_id", "user"]
```

Enitity.User.yml
``` yml
FoobarBundle\Entity\User:
    exclusion_policy: ALL
    properties:
        id:
            expose: true
        user_id:
            expose: true
        email:
            expose: true
        firstName:
            expose: true
        middleName:
            expose: true
        lastName:
            expose: true

```

{'fraction_non_alphanumeric': 0.09997890740350138, 'fraction_numerical': 0.0, 'mean_word_length': 3.1706244503078276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6753052', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1333, 'n_words': 380}