An easy way to perform background job processing in your applications.
Poist is a reliable application to perform backgrouund jobs. Currently it has the following features.
- Has a scheduler that supports cron jobs.
- Has web sockets support.
- Supports multiple threads in a scheduler
- Supports multiple threads in a consumer.
- Supports Hibernate ORM
- Poist is cross platform
- Makes use of Rabbit MQ and Spring AMQP
- Its easy to modify and use compared to other solutions such as Resque, Sidekiq, delayed_job, Celery,Quartz Scheduler,Hangfire,Gearman
Install Java JRE
sudo apt-get install default-jre
Install Maven
sudo apt-get install maven
Install Rabbit MQ
First, use the following commands to add erlang apt repository on your system. You can simply download erlang repository package from its official website and install on your system.
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
Now, you can install erlang package on your system using the following command. This will install all of its dependencies as well.
sudo apt-get update
sudo apt-get install erlang erlang-nox
After installing requirements, now enable RabbitMQ apt repository on your system. Also you need to import rabbitmq signing key on your system. Use the following commands to do this.
echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
After that update apt cache and install RabbitMQ server on your system.
sudo apt-get update
sudo apt-get install rabbitmq-server
After completing installations, enable the RabbitMQ service on your system. Also, start the RabbitMQ service. Use one the below methods sysvinit for older systems or systemctl for the latest operating system.
Using Init –
sudo update-rc.d rabbitmq-server defaults
sudo service rabbitmq-server start
sudo service rabbitmq-server stop
Using Systemctl –
sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server
sudo systemctl stop rabbitmq-server
By default rabbitmq creates a user named “guest” with password “guest”. You can also create your own administrator account on RabbitMQ server using following commands. Change password with your own password.
sudo rabbitmqctl add_user admin password
sudo rabbitmqctl set_user_tags admin administrator
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
RabbitMQ also provides and web management console for managing the entire RabbitMQ. To enable web management console run following command on your system. The web management console helps you for managing RabbitMQ server.
sudo rabbitmq-plugins enable rabbitmq_management
RabbitMQ dashboard starts on port 15672. Access your server on the port to get dashboard. Use the username and password created in step 4
Install the stomp plugin https://www.rabbitmq.com/stomp.html using this command
rabbitmq-plugins enable rabbitmq_stomp
and also the web stomp plugin
https://www.rabbitmq.com/web-stomp.html
rabbitmq-plugins enable rabbitmq_web_stomp
Check if you have the plugins using this command
rabbitmq-plugins list
Install Mysql (this is only needed to demonstrate how to connect to any database that is supported by Hibernate ORM)
sudo apt-get install mysql-server
Install Mysql driver for java
sudo apt-get install libmysql-java
Once you have installed everything,simply clone poist
git clone https://github.com/britisharmy/poist.git
and adjust your database connection details here https://github.com/britisharmy/poist/blob/master/amqp/src/main/resources/application.properties
and start poist
mvn jetty:run
You can learn how to use poist with codeigniter here https://github.com/britisharmy/codeigniter-poist
and connect to poist using the code below.
<script src="//cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.1.2/sockjs.min.js"></script>
<script src="stomp.js"></script>
<script type="text/javascript">
var ws = new SockJS("http://your-ip:15674/stomp");
var client = Stomp.over(ws);
client.heartbeat.outgoing = 0;
client.heartbeat.incoming = 0;
var onConnect = function() {
client.subscribe("/topic/messages", function(d) {
var str = d.body
var res = str.match(/Body:\'(.+)\'/);
console.log("I control this",res[1]);
});
};
var onError = function(e) {
console.log("ERROR", e);
};
client.connect("admin", "adminpassword", onConnect, onError, "/");
</script>
Build powerful and feature-rich realtime chat apps. Cross-device and cross-platform means they work across web, iOS, Android, and the rest.
Securely monitor, control, provision and stream data between smart devices, sensor networks, hubs, and more. Trigger device action, monitor meta data, or stream and process incoming and outgoing data.
Keep everyone, and every device realtime. From mapping, geotracking and dispatch, to broadcasting push notifications and up-to-the-millisecond alerts, when something happens in the real world, it's reflected in your app.
Build realtime collaborative tools and environments for apps that allow teams to work together better
MIT License (c) Geoffrey