To get the framework up and running we will make the following assumptions regarding software that we will be using:
To simplify our setup we will install all the related Smartbox bundles
Add the following to composer.json and run composer install
"smartbox/core-bundle": "^1.0.0",
"smartbox/integration-framework-bundle": "^1.20.4",
"smartbox/camel-config-bundle": "^1.0.0",
"smartbox/besimple-soap": "^1.1.1"
To update to the latest smartbox bundle versions please run
composer update smartbox/integration-framework-bundle smartbox/core-bundle smartbox/camel-config-bundle smartbox/besimple-soap
Install all the necessary dependencies on Ubuntu: Apache, MySql and PHP Stack.
sudo apt-get install -y mysql-server mysql-client
sudo apt-get install -y apache2
sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip php7.0-dev
sudo apt-get install -y php7.0-curl php7.0-xml php7.0-soap php-apcu php-apcu-bc
Install and configure RabbitMQ. This will:
sudo apt-get install rabbitmq-server
rabbitmq-plugins enable rabbitmq_management
rabbitmq-plugins enable rabbitmq_stomp
rabbitmqctl add_user mel mel
rabbitmqctl set_user_tags mel administrator
rabbitmqctl set_permissions -p / mel "." "." ".*"
sudo touch /etc/rabbitmq/rabbitmq.config
echo "[{rabbit, [{loopback_users, []}]}]." | sudo tee /etc/rabbitmq/rabbitmq.config
echo -e "\n127.0.0.1 rabbitmq.local" | sudo tee -a /etc/hosts
Install Supervisor on Ubuntu:
sudo apt-get install supervisor
To create a consumer that will be controlled by Supervisor, we can add a .conf file to the supervisor configurations directory. For example:
/etc/supervisor/conf.d/SuperHardWorker.conf
which would contain contents as follows:
[program:consumer_db_queue]
process_name = %(program_name)s_%(process_num)02d
autostart = true
autorestart = true
numprocs=10
directory=/var/www/skeleton/
command = php app/console smartesb:consumer:start queue://main/persist --killAfter=200
stdout_logfile = /home/mel/stdout.log
stderr_logfile = /home/mel/stderr.log
startretries = 10
user = mel
Note that the value numprocs=10
means that supervisor will attempt to always run 10 instances/processes of the program.