Here you can find BCs generated for the AppCivist project. These BCs were automatically generated by Social-MQ.
- RabbitMQ
- Node.js
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).
- AMQP (for all BCs): you can find the AMQP configuration in the files
amqp-endpoint.conf.js.sample
oramqp-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'
}
};
-
HTTP Senders: the files
http-sender.conf.json.sample
orhttp-sender.conf.js.sample
contain the address of the HTTP endpoint to send the message to. -
HTTP Endpoints: the file
hhttp-endpoint.conf.js.sample
contains the port to listen to and the request path for the endpoint. -
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.
There is no specific way of running BCs; however, we recommend to follow the best production practices described in:
- Install the Strong Loop Process Manager
npm install -g strong-pm
- 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
- 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.
- Components:
- http-endpoint: it is an HTTP server exposing a POST method.
- 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>"
}'
- Components:
- amqp-endpoint: it subscribes to the AMQP broker and waits for new messages for Email.
- smtp-sender: it sends received messages via email.
- Components:
- amqp-endpoint: it subscribes to the AMQP broker and waits for new messages for Email.
- http-sender: it sends received messages via HTTP using Webhooks.
- Components:
- amqp-endpoint: it subscribes to the AMQP broker and waits for new messages for Email.
- http-sender: it sends received messages to the Subscription Manager service..
- Components:
- amqp-endpoint: it subscribes to the AMQP broker and waits for new messages for Email.
- http-sender: it sends received messages to the Slack Channel service.
You can also find some additional services you can play with. They are already participating in the Social Communication Bus.