// Path: berserker-commons/src/main/java/io/smartcat/berserker/api/Worker.java
// public interface Worker<T> {
// 
//     /**
//      * Accepts message of type {@code <T>} and processes it.
//      *
//      * @param message Message which will be processed.
//      * @param commitSuccess Callback to be invoked when processing is successful.
//      * @param commitFailure Callback to be invoked in case of a failure.
//      */
//     void accept(T message, Runnable commitSuccess, Runnable commitFailure);
// }


import java.util.Map;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import io.smartcat.berserker.api.Worker;
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void accept(Map<String, Object> message, Runnable commitSuccess, Runnable commitFailure) {
        ensureConnected();
        String topic = (String) message.get(TOPIC);
        int qos = (Integer) message.get(QOS);
        String payload = (String) message.get(PAYLOAD);
        MqttMessage mqttMessage = new MqttMessage(payload.getBytes());
        mqttMessage.setQos(qos);
        try {
            IMqttDeliveryToken token = client.publish(topic, mqttMessage, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    commitSuccess.run();
                }

                @Override
                public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
                    commitFailure.run();
                }
            });
            if (!async) {
                token.waitForCompletion();
            }
        } catch (Exception e) {
// Path: berserker-commons/src/main/java/io/smartcat/berserker/api/Worker.java
// public interface Worker<T> {
// 
//     /**
//      * Accepts message of type {@code <T>} and processes it.
//      *
//      * @param message Message which will be processed.
//      * @param commitSuccess Callback to be invoked when processing is successful.
//      * @param commitFailure Callback to be invoked in case of a failure.
//      */
//     void accept(T message, Runnable commitSuccess, Runnable commitFailure);
// }


// Path: berserker-mqtt/src/main/java/io/smartcat/berserker/mqtt/worker/MqttWorker.java
import java.util.Map;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import io.smartcat.berserker.api.Worker;

            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void accept(Map<String, Object> message, Runnable commitSuccess, Runnable commitFailure) {
        ensureConnected();
        String topic = (String) message.get(TOPIC);
        int qos = (Integer) message.get(QOS);
        String payload = (String) message.get(PAYLOAD);
        MqttMessage mqttMessage = new MqttMessage(payload.getBytes());
        mqttMessage.setQos(qos);
        try {
            IMqttDeliveryToken token = client.publish(topic, mqttMessage, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    commitSuccess.run();
                }

                @Override
                public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
                    commitFailure.run();
                }
            });
            if (!async) {
                token.waitForCompletion();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);