import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.QueueingConsumer;

import java.io.IOException;

public class Receiver {
    private Channel channel;
    QueueingConsumer consumer;
    private final static String HOST_NAME = "localhost";
    private final static String QUEUE_NAME = "task_queue";

    /**
     * set parameters for RabbitMQ receiver
     */
    public Receiver() {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost(HOST_NAME);
        Connection connection = null;
        try {
            connection = factory.newConnection();
            channel = connection.createChannel();

            /*
            * a client can be assigned only 1 message, the next message will be
            * assigned only after it finishes processing the first message
            */
            int prefetchCount = 1;

            channel.basicQos(prefetchCount);
            boolean durable = true;
            channel.queueDeclare(QUEUE_NAME, durable, false, false, null);
            consumer = new QueueingConsumer(channel);
            boolean autoAck = false;
            channel.basicConsume(QUEUE_NAME, autoAck, consumer);


        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * Listen for messages
     */
    public void startReceiving() {
        while (true) {
            try {
                QueueingConsumer.Delivery delivery = consumer.nextDelivery();
                String message = new String(delivery.getBody());
                executeCommand(message);
                channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
                System.out.println("[X] Done");
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * Start a command with received message
     *
     * @param command terminal command that will be executed
     * @throws InterruptedException
     */
    private void executeCommand(String command) throws InterruptedException {
        Command cmd = new Command(command);
        cmd.execute();
    }
}

@@ -158,16 +158,42 @@
 onsumer;
+%0Aimport datamodel.Command;
 %0A%0Aimport
@@ -268,24 +268,32 @@
 hannel;%0A    
+private 
 QueueingCons
@@ -364,16 +364,16 @@
 lhost%22;%0A
-
     priv
@@ -422,16 +422,67 @@
 _queue%22;
+%0A    RabbitMqConfig rmqConf = new RabbitMqConfig();
 %0A%0A    /*
@@ -2309,16 +2309,24 @@
  Command
+Executor
  cmd = n
@@ -2339,16 +2339,17 @@
 mand
-(command
+Executor(
 );%0A 
@@ -2367,16 +2367,36 @@
 execute(
+new Command(command)
 );%0A    %7D

Update for new way of handling commands.