Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[WIP] Bundle architecture / configuration logic #66

Closed
wants to merge 6 commits into from

3 participants

@benjamindulau

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:
<tag name="old_sound_rabbit_mq.consumer" id="user_activity" connection="default" exchange="app_direct" queue="user_activity" />

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 has 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:

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 ?

benjamindulau added some commits
@benjamindulau benjamindulau [WIP] 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:
<tag name="old_sound_rabbit_mq.consumer" id="user_activity" connection="default" exchange="app_direct" queue="user_activity" />

 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).
b6a2351
@benjamindulau benjamindulau Fixed attributeAsKey in Configuration 2d578e5
@mvrhov

I like the shorter configuration :)

@videlalvaro
Owner

I'm aware of the PR. I'll take a look soon. I'm traveling now

@benjamindulau

I'm closing the PR, i'm still working on it but i need to clean some code and make different atomic PRs.

@videlalvaro
Owner

Sorry I haven't chimed at all but I've been pretty busy lately.

@benjamindulau

@videlalvaro No worries, i'm working on this for a project in development so it's not consistent yet. Changing a bit every day. I'll reopen small PRs after i'm happy with my choices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 8, 2012
  1. @benjamindulau

    [WIP] This commit introduces some important changes.

    benjamindulau authored
    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:
    <tag name="old_sound_rabbit_mq.consumer" id="user_activity" connection="default" exchange="app_direct" queue="user_activity" />
    
     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).
Commits on Oct 10, 2012
  1. @benjamindulau
Commits on Oct 15, 2012
  1. @benjamindulau

    Uncommented needed code

    benjamindulau authored
Commits on Oct 18, 2012
  1. @benjamindulau
Commits on Oct 25, 2012
  1. @benjamindulau
  2. @benjamindulau

    Added an event dispatch after consumer consume method. This can be us…

    benjamindulau authored
    …eful if the developer wants to do some end operations, like closing MySQL connection for instance ;-)
Something went wrong with that request. Please try again.