Skip to content

socialappslab/socialbus-bc

 
 

Repository files navigation

AppCivist Binding Components (BCs)

Here you can find BCs generated for the AppCivist project. These BCs were automatically generated by Social-MQ.

Requirements for running The BCs

  • RabbitMQ
  • Node.js

Configuring the BCs

All configuration files are located in the conf folder inside the BC's root folder. You have to rename the files name *.conf.js.sample to *.conf.js. Configuration parameters depend on the type of the BC; however, all BCs have either and AMQP endpoint (subscriber) or an AMQP sender (publisher).

  1. AMQP (for all BCs): you can find the AMQP configuration in the files amqp-endpoint.conf.js.sample or amqp-sender.conf.js.sample. It contains the information of the AMQP broker, including the name of the exchange to publish or subscribe to.
module.exports = {
    address: '127.0.0.1',
    port: '5672',
    user: 'username',
    password: 'userpass',
    exchange:{
      name:'exchange-name',
      type:'fanout'
    }
};
  1. HTTP Senders: the files http-sender.conf.json.sample or http-sender.conf.js.sample contain the address of the HTTP endpoint to send the message to.

  2. HTTP Endpoints: the file hhttp-endpoint.conf.js.sample contains the port to listen to and the request path for the endpoint.

  3. Some BC (e.g., email) might require extra configuration for the components used in the lib folder. For example, the bus-email requires a valid SMTP account to be configured in lib/mailer.conf.js

module.exports = {
    host: 'smtp.example.com',
    port: 465,
    email: 'user',
    password: 'pass'
};

Finally, you have to install the required modules of each BC using the command npm install in the BC's root folder.

How to run the BCs

There is no specific way of running BCs; however, we recommend to follow the best production practices described in:

  1. Install the Strong Loop Process Manager
npm install -g strong-pm
  1. Install Process Manager as a service to ensure it starts when the system boots
# Ubuntu 12.04+:
sudo sl-pm-install
sudo /sbin/initctl start strong-pm 

# Red Hat Enterprise Linux 7+:
sudo sl-pm-install --systemd
sudo /usr/bin/systemctl start strong-pm 

# Red Hat Enterprise Linux 5 and 6:
sudo sl-pm-install --upstart=0.6
sudo /sbin/initctl start strong-pm
  1. Use the slc to run the BC (this way, BCs restart automatically if they crash).
# Build and run
cd $BC_DIR
//install node dependencies
npm i
//build for a Git repository
slc build
//build for a non-Git repository or to deploy subdirectories of a Git repository
slc build --pack
//deploy
slc deploy

# See BCs running
slc ctl ls

Id            Name            Scale
 1   bc-appcivistnorifier-bus.email    1
 2       bc-bus-email                  1
 3      bc-bus-http                    1
 4     bc-bus-slackchannel             1

The main file of BCs is called start-bc and it is located inside the BC's root folder. To execute a BC, you have to run this file. How to run it depends on the platform the BC was generated for.

  • Node.js BC execution: node start-bc.js, slc start using the Strong Loop Process Manager locally, or deploy it using slc build and slc deploy.

The AppCivist Notifier to Email BC

  • Components:
  1. http-endpoint: it is an HTTP server exposing a POST method.
  2. amqp-sender: it sends received messages to Email through the AMQP broker.
  • Dummy Producer:

There are two types of the HTTP producer: one sending x-www-form-urlencoded data (no longer supported); the other sending json data. Both types of producers are available in Java and un curl. For example,

curl -X POST http://localhost:3000/email\
    -H "Content-Type: application/json"\
    -d '{"to":["[email protected]","[email protected]"],
    "from":"AppCivist Bot <[email protected]>",
    "subject":"This is just a test!",
    "text":"<html><p><strong>Example Email from AppCivist</strong></p> <img src=\"http://www.airport-orly.com/images/paris-tour-eiffel-at-night.jpg\" alt=\"Mountain View\" style=\"width:304px;height:228px;\"></html>"
    }'

The Email BC

  • Components:
  1. amqp-endpoint: it subscribes to the AMQP broker and waits for new messages for Email.
  2. smtp-sender: it sends received messages via email.

The HTTP Webhook BC

  • Components:
  1. amqp-endpoint: it subscribes to the AMQP broker and waits for new messages for Email.
  2. http-sender: it sends received messages via HTTP using Webhooks.

The Subscription Manager BC

  • Components:
  1. amqp-endpoint: it subscribes to the AMQP broker and waits for new messages for Email.
  2. http-sender: it sends received messages to the Subscription Manager service..

The Slack Channel BC

  • Components:
  1. amqp-endpoint: it subscribes to the AMQP broker and waits for new messages for Email.
  2. http-sender: it sends received messages to the Slack Channel service.

More

You can also find some additional services you can play with. They are already participating in the Social Communication Bus.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 71.4%
  • Java 25.6%
  • Shell 3.0%