Coder Social home page Coder Social logo

message_broker_producer's Introduction

##Message Broker Producer

This Drupal 7 module provides producer access to the Message Broker / Quicksilver system.

  • Wrapper function for Object Library calls
  • Administration pages:
    • RabbitMQ authentication configuration
    • Add/Edit/Delete Productions
      • Productions are a collection of settings for connecting to a RabbitMQ server that define exchange and related queue settings.
    • Queue status

Requirements:

Administration Access:

  • Once the module is enable goto: /admin/config/services/message-broker-producer

Sponsored by DoSomething.org

message_broker_producer's People

Contributors

deezone avatar aaronschachter avatar sergiitk avatar

Watchers

Andrea Gaither avatar James Cloos avatar Mai Irie avatar Noah Nakell avatar Sahil Gupta avatar wercker avatar Katie Crane avatar Gleb Boundin avatar  avatar Anton Halim avatar Toyin Robinson  avatar Lindsay Maher avatar Vanessa Gibbs avatar Kevin Deguzman avatar  avatar

message_broker_producer's Issues

Hide routing key and enable/disable settings in production creation form

When a new production entry is created hide the:

  • routing key
  • enable / disable settings
    This settings will be made available in the edit state of the form where the exchange and related queues has been selected. The exchange type and queue bindings define what a valid production message key can be.

A production entry can only be enabled when a valid routing key is defined.

Add GPL2/3 license

While all DS repos are MIT licensed Drupal modules require GPL. Add GPL license file to this repo.

Transactional test entries

Add test links to the message_broker_producer module for each of the transactional types:

  • user_register
  • user_password
  • campaign_signup
  • campaign_reportback

to produce test transactions. Support payload formats for each of the transactional types as defined in dosomething_user.module dosomething_user_mbp_request()

Related Trello card: https://trello.com/c/EsFN1kwc

Coder review of .install file

Run the .install file through the Coder standards and fix the errors found unless there's a compelling reason not to.

Format RabbitMQ status details

@tz-earl as discussed, complete RabbitMQ status reports based on cURL API calls to the Rabbit Management API. See message_broker_producer_status() for the cURL calls and the related message-broker-producer-status.tpl.php template to format the output.

Don't forget to drush cc all whenever you make template changes.

Add "delete" to admin interface for Productions

  • Add general delete functionality for production entries in the message_broker_producer database table.
  • Add delete link from production listing table
  • Delete should have a confirmation step to ensure entries are not mistakenly removed.

Report missing messagebroker-phplib library

Calls to message_broker_producer_request() in Drupal 7 module should report missing messagebroker-phplib library to support correct installation.

This should also include a test for messagebroker-config.

Add support for binding_patterns

Add support for binding_patterns as an array vs a single binding_pattern as a string. When loading the queue config, if more than one binding_pattern is detected:

  • create additional queue entries / connections using each pattern.
  • don't define the consumer_tag, allow Rabbit to auto create with each binding as a consume option

Install Bug

DEBUG [15ad1e54] PHP Parse error: syntax error, unexpected T_IS_NOT_EQUAL in /var/www/beta.dosomething.org/releases/20141104153348/html/profiles/dosomething/modules/contrib/message_broker_producer/message_broker_producer.install on line 168
DEBUG [15ad1e54] Drush command terminated abnormally due to an unrecoverable error. [error]
DEBUG [15ad1e54] Error: syntax error, unexpected T_IS_NOT_EQUAL in

Sample message_broker_producer_request('produceTransactional', $payload) calls

Create outline of how to use message_broker_producer_request('produceTransactional', $payload) in New World app.

Examples for:

  • New User Registration
  • User Password Reset
  • Campaign Signup
  • Campaign Report Back

Example:

$payload = array(
    'activity' => 'campaign-signup',
    'event_id' => 8012345,
    'email' => '[email protected]',
    'merge_vars' => array(
      'FNAME' => 'First-Name',
      'CAMPAIGN-TITLE' => 'Campaign Test Title',
      'ACTION' => 'Some call to action',
      'STEP-ONE' => 'Step one from Do It',
      'STEP-TWO' => 'Step two from Do It',
      'STEP-THREE' => 'Step three from Do It',
  ),
);
message_broker_producer_request('produceTransactional', $payload);

Need a better way to refresh existing Production records if the config file changes

Currently the only way to do this, would be to go to the admin form for the production, e.g.
http://dev.dosomething.org:8888/admin/config/services/message-broker-producer/add-edit-production/transactional_campaign_group_signup

click the "Reload queues from config file.", and then re-de-select the queues to include.

Ideally, the record updates itself with the queues you want, but reading the config file and updating the entry. If you're changin the config file, the module should automatically find the update and make it... shouldn't have to manually refresh the production yourself.

Add message_broker_producer database table

Add database table to store "production" settings. The table will consist the columns:

  • machine_name : to be referenced by message_broker_producer_request()` calls. (Unique string).
  • config : Selected exchanges and the related queues. (serialized string)
  • status : Enable / disable entry (boolean)
  • last_update : The last time the config settings were refreshed from the mb_config.json file. (integer timestamp). The table will reference what exchange / queue settings to include in the message_broker_producer_requests() based on the machine_name sent in the request.
  • Create hook_schema() entry in .install
  • hook_uninstall() to remove table
  • enable_enable() to confirm module installation
  • Update hook_requirements to include messagebroker-config.

Related Issue:
#32

Monitor RabbitMQ queue status

From the Drupal module: admin/config/services/message-broker-producer lists the RabbitMQ status for:

// List queues
rabbitmqctl list_queues

// List exchanges
rabbitmqctl list_exchanges

// List bindings
rabbitmqctl list_bindings

Rename productionType

Low priority task but a nice to have.

Per our walkthrough yesterday, the productionType variable is storing what RabbitMQ Exchange to send the request to. The code would be a bit more readable if %productionType was renamed to something like $exchange_name (keep lowercase / underscores for Drupal standards?)

Hardcoded DS config file

This is more of a placeholder for discussion and not high priority (or even low priority?), but if this module is to be used by any external non DS use, there wouldn't be much use for the DS Message Broker config library.

Module could potentially be altered to just read a file from a URL stored in a variable.

Datatable storage for configuration

Also a nice to have, but possibly not necessary. Adding an issue for possible enhancement but mainly for documentation / discussion.

The variables used for Producer Configuration (admin/config/services/message-broker-producer/mq-settings) could be implemented using a datatable. This way we wouldn't need to add a new fieldset to add new queues, but would simply add a new record to a queues datatable.

Refactoring to use this architecture would make the module a bit more friendly towards open-source / usage by others.

Campaign Reportback PhpAmqpLib error

WHen reporting back to https://staging.beta.dosomething.org/node/17

Warning: fwrite() expects parameter 1 to be resource, null given in PhpAmqpLib\Wire\IO\StreamIO->write() (line 61 of /var/www/beta.dosomething.org/releases/20140408203302/html/profiles/dosomething/libraries/messagebroker-phplib/vendor/videlalvaro/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php).
Warning: fwrite() expects parameter 1 to be resource, null given in PhpAmqpLib\Wire\IO\StreamIO->write() (line 61 of /var/www/beta.dosomething.org/releases/20140408203302/html/profiles/dosomething/libraries/messagebroker-phplib/vendor/videlalvaro/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php).

Add "update" to admin interface for Productions

Add "update" of CRUD admin functionality to edit production entry in message_broker_producer database table.

  • Load existing production entry in message_broker_producer_production_options_form() based on machine_name passed in URL. Ex: admin/config/services/message-broker-producer/add-edit-production/%
  • Add link to production listing for each entry that loads entry in edit form
  • In production entry edit form add checkbox form elements to queues assigned to the exchange to allow for loading of specific queues in production entry.

Producer Tests

Ways to trigger message_broker_producer_request() test:

  • Add link to admin page
  • Drush command

Rename database

Rename the database message_broker_producer to message_broker_producer_productions.

Add support for "cacheCampaign" transactions

Add support for '"produceCampaign" transactions.

  • Add support for connecting to "cacheExchange" and "cacheQueue"
  • Pass payload to exchange$messageBroker->publishMessage($message) call.
  • Refactor message_broker_producer_request() to support "produceTransactional" and "produceCampaignCache" $method.

See for the addition of related functionality:
DoSomething/legacy-website#1844

If status is not "ok", show current host, port, etc. instead.

If the initial call to RabbitMQ does not return a status of "ok", then show the current host, port, user, and vhost as recorded in the database. Skip the other api calls and suppress the normal output.

Support for vhost setting. Currently it appears the cURL calls are connecting to the default ("/") vhost.

Refactor message_broker_producer_request()

Refactor message_broker_producer_request() to use the production settings in the message_broker_producer table.

  • rename $productionType to $production where $production is an entry in the message_broker_producer table that defines the exchange and queues to send the request to.
  • connect / define $config values to the exchange and queues based on the settings in production entry requested
  • remove the $param['activity'] logic and use production entries that include $routing_key values

Add "create" of CRUD admin functionality

Add "create" of CRUD admin functionality for message_broker_producer_production_options_form() to add production entry to the message_broker_producer database table.

  • Create form elements at admin/config/services/message-broker-producer/production-options -> message_broker_producer_production_add_update()
    • production_name (string) - text field
    • exchange (string) - select
    • routing key (string) - text field
    • status (boolean) - checkbox
      Note: Use pass-thru function to allow the passing of the machine_name to target entries for update "U" functionality.
  • Validate values submitted for production entry:
    • machine_name must be unique
    • An exchange must be selected
  • Add SQL in message_broker_producer_production_options_form_submit() to support SUBMIT to message_broker_producer database table.

Remove Admin Exchange and Queue setting form

Remove admin interface based exchange and queue settings. The settings will be managed by the values in mb_config.json.

  • Remove admin form elements
  • Provide admin interface to select exchange and related queues
  • Store selection in Drupal variables table
  • List selected exchange and related queue settings for reference.

Add userAPIRegistrationQueue

To support the UserAPI (https://github.com/DoSomething/mb-users-api) that will store user related data.

  • New user registration transaction details will be queued (user.registration.*) in userAPIRegistrationQueue to be consumed by mbc-userAPI-newUser
  • User activity in campaigns (sign up and report backs) will be queued (campaign..) in userAPICampaignActivity to be consumed by mbc-userAPI-campaignActivity

See:
Campaign activity: DoSomethingArchive/message-broker#22
New Users: DoSomethingArchive/message-broker#35

Add message_broker_producer_payloads table

  • Add support for message_broker_producer_payloads table.
    • Key/value table row values define message payload values for message_broker_producer_productions entry based on production_id.
  • Add production_id to message_broker_producer_productions
  • Admin interface to manage Key/value/production_id values.

Notes:

  • support for token replacement using ['token']['<name>'] = <value> in message_broker_producer-request() call

Load mb_config.json

  • Load exchange and queue settings from mb_config.json
  • Adjust admin interface to present possible exchange / queue settings for use by the module when producing entries in a RabbitMQ system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.