videlalvaro/RabbitMqBundle — pull request #66 by benjamindulau (2012-10-08 11:03:26+00:00)
Title: [WIP] Bundle architecture / configuration logic

**Be careful, this PR is not ready for merging but represents a proposal. Some work has yet to be done.**

I just copy/paste the commit message here, so you understand what this is about:

> This commit introduces some important changes.
>
> First it changes a bit the architecture.
>
> It introduces tow objects Queue and Exchange which factor queue/exchanges options in one place. These is needed to be able to get the full producer/exchanges/queues/bindings configuration in one place for performing some operations like creating exchanges/queues and their bindings.
> This is what the new Manager/ConfigPool objects are intended to. Instead of keeping a copy of all exchange options, the producer new holds a reference to the associated Exchange object. As well as the Consumer now holds two references, one to the associated Queue object, and one to the Exchange one.
> This makes the whole thing more consistent since the same Exchange/Queue references are shared between accross the system instead of a duplicate of options in each object.
>
> As a bonus, the consumers now can be declared as tagged services, example:
> ``` ```
>
> A Consumer compiler pass now creates automatically consumers services associated to user tagged services. If the given exchange/queue already exist in the configuration, they are used, otherwise, default ones are created (see defaultOptions in Exchange/Queue classes).
>
> So far so good, i also added two new console commands:
> - One for creating automatically exchanges/queues and bindings
> - One for purging existing queues This is a work in progress, and some work are yet to be done and > some pieces have to be updated/re-introduced (for now, some code is hard commented).

The configuration now looks like the following:

```YAML
old_sound_rabbit_mq:
connections:
default:
is_default: true
host: %rabbitmq.host%
port: %rabbitmq.port%
user: %rabbitmq.user%
password: %rabbitmq.password%
vhost: '/'
exchanges:
app_direct:
type: direct
passive: false
durable: true
auto_delete: false
internal: false
nowait: false
ticket: ~
bindings:
- {queue: post_processing, routing_key: post_processing}
- {queue: permission, routing_key: permission}
- {queue: index, routing_key: index}
- {queue: following_encode, routing_key: following_encode}
- {queue: user_activity, routing_key: user_activity}
- {queue: build_feed, routing_key: build_feed}
- {queue: user_notification, routing_key: user_notification}
- {queue: user_invite, routing_key: user_invite}
producers:
main:
connection: default
exchange: app_direct
```

What do you think ?