// Path: camunda-task-dispatcher-api/src/main/java/com/ae/camunda/dispatcher/api/completer/Status.java
// public enum Status {
//     COMPLETE, FAIL
// }
// 
// Path: camunda-task-dispatcher-api/src/main/java/com/ae/camunda/dispatcher/api/jms/Headers.java
// public interface Headers {
//     String PREFIX = "CamundaTaskDispatcher";
// 
//     String STATUS = PREFIX + "Status";
// 
//     String REASON = PREFIX + "Reason";
// 
//     String DETAIL = PREFIX + "ReasonDetail";
// }
// 
// Path: camunda-task-dispatcher-api/src/main/java/com/ae/camunda/dispatcher/api/manager/ExternalTaskManager.java
// public interface ExternalTaskManager {
//     List<FetchExternalTasksDto.FetchExternalTaskTopicDto> getExternalTaskTopics(long lockTimeout);
// 
//     Object toCommand(LockedExternalTaskDto task);
// 
//     static String toTaskName(Class<?> aClass) {
//         CamundaTask annotation = aClass.getAnnotation(CamundaTask.class);
//         if (annotation == null) {
//             throw new IllegalArgumentException("Class " + aClass.getName() + " must have annotation com.ae.camunda.dispatcher.api.annotation.CamundaTask");
//         } else {
//             return Strings.isNullOrEmpty(annotation.value()) ? aClass.getName() : annotation.value();
//         }
//     }
// 
//     Class<?> getCommandClass(String taskName);
// 
//     Pair<String, CompleteExternalTaskDto> toCompleteTask(String taskName, Object command);
// 
//     Pair<String, ExternalTaskFailureDto> toFailTask(String taskName, Object command);
// 
//     static String getVarName(Field field, CamundaVar camundaVar) {
//         return Strings.isNullOrEmpty(camundaVar.value()) ? field.getName() : camundaVar.value();
//     }
// }
// 
// Path: camunda-task-dispatcher-api/src/main/java/com/ae/camunda/dispatcher/api/mapper/TaskMapper.java
// public interface TaskMapper {
//     String map(Object task);
//     Object map(String body, Class<?> clazz);
// }


import javax.jms.TextMessage;
import com.ae.camunda.dispatcher.api.completer.Status;
import com.ae.camunda.dispatcher.api.jms.Headers;
import com.ae.camunda.dispatcher.api.manager.ExternalTaskManager;
import com.ae.camunda.dispatcher.api.mapper.TaskMapper;
import com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.Session;

    @Autowired
    private JmsTemplate jmsTemplate;

    public void send(Object task, Status status) {
        send(task, queueIn, status, null, null);
    }

    public void send(Object task, Status status, String reason) {
        send(task, queueIn, status, reason, null);
    }

    public void send(Object task, Status status, String reason, String detail) {
        send(task, queueIn, status, reason, detail);
    }

    private void send(Object task, String queue, Status status, String reason, String detail) {
        jmsTemplate.send(queue, (Session session) -> {
            TextMessage message = session.createTextMessage();
            message.setText(taskMapper.map(task));

            if (!Strings.isNullOrEmpty(header)) {
                setStringProperty(message, header, ExternalTaskManager.toTaskName(task.getClass()));
            }

            if (status != null) {
                setStringProperty(message, Headers.STATUS, status.name());
            }

            if (!Strings.isNullOrEmpty(reason)) {
// Path: camunda-task-dispatcher-api/src/main/java/com/ae/camunda/dispatcher/api/completer/Status.java
// public enum Status {
//     COMPLETE, FAIL
// }
// 
// Path: camunda-task-dispatcher-api/src/main/java/com/ae/camunda/dispatcher/api/jms/Headers.java
// public interface Headers {
//     String PREFIX = "CamundaTaskDispatcher";
// 
//     String STATUS = PREFIX + "Status";
// 
//     String REASON = PREFIX + "Reason";
// 
//     String DETAIL = PREFIX + "ReasonDetail";
// }
// 
// Path: camunda-task-dispatcher-api/src/main/java/com/ae/camunda/dispatcher/api/manager/ExternalTaskManager.java
// public interface ExternalTaskManager {
//     List<FetchExternalTasksDto.FetchExternalTaskTopicDto> getExternalTaskTopics(long lockTimeout);
// 
//     Object toCommand(LockedExternalTaskDto task);
// 
//     static String toTaskName(Class<?> aClass) {
//         CamundaTask annotation = aClass.getAnnotation(CamundaTask.class);
//         if (annotation == null) {
//             throw new IllegalArgumentException("Class " + aClass.getName() + " must have annotation com.ae.camunda.dispatcher.api.annotation.CamundaTask");
//         } else {
//             return Strings.isNullOrEmpty(annotation.value()) ? aClass.getName() : annotation.value();
//         }
//     }
// 
//     Class<?> getCommandClass(String taskName);
// 
//     Pair<String, CompleteExternalTaskDto> toCompleteTask(String taskName, Object command);
// 
//     Pair<String, ExternalTaskFailureDto> toFailTask(String taskName, Object command);
// 
//     static String getVarName(Field field, CamundaVar camundaVar) {
//         return Strings.isNullOrEmpty(camundaVar.value()) ? field.getName() : camundaVar.value();
//     }
// }
// 
// Path: camunda-task-dispatcher-api/src/main/java/com/ae/camunda/dispatcher/api/mapper/TaskMapper.java
// public interface TaskMapper {
//     String map(Object task);
//     Object map(String body, Class<?> clazz);
// }


// Path: camunda-task-dispatcher-completer-jms/src/main/java/com/ae/camunda/dispatcher/completer/jms/JmsExternalTaskSender.java
import javax.jms.TextMessage;
import com.ae.camunda.dispatcher.api.completer.Status;
import com.ae.camunda.dispatcher.api.jms.Headers;
import com.ae.camunda.dispatcher.api.manager.ExternalTaskManager;
import com.ae.camunda.dispatcher.api.mapper.TaskMapper;
import com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.Session;


    @Autowired
    private JmsTemplate jmsTemplate;

    public void send(Object task, Status status) {
        send(task, queueIn, status, null, null);
    }

    public void send(Object task, Status status, String reason) {
        send(task, queueIn, status, reason, null);
    }

    public void send(Object task, Status status, String reason, String detail) {
        send(task, queueIn, status, reason, detail);
    }

    private void send(Object task, String queue, Status status, String reason, String detail) {
        jmsTemplate.send(queue, (Session session) -> {
            TextMessage message = session.createTextMessage();
            message.setText(taskMapper.map(task));

            if (!Strings.isNullOrEmpty(header)) {
                setStringProperty(message, header, ExternalTaskManager.toTaskName(task.getClass()));
            }

            if (status != null) {
                setStringProperty(message, Headers.STATUS, status.name());
            }

            if (!Strings.isNullOrEmpty(reason)) {
                setStringProperty(message, Headers.REASON, reason);