// Path: generatedata/src/main/java/initdata/publish/model/Messages.java
// public class Messages {
//     private Map<String, String> messageHeader;
//     private List<MessagesDef> messages;
//     public Map<String, String> getMessageHeader() {
//         return messageHeader;
//     }
// 
//     public void setMessageHeader(Map<String, String> messageHeader) {
//         this.messageHeader = messageHeader;
//     }
// 
//     public List<MessagesDef> getMessages() {
//         return messages;
//     }
// 
//     public void setMessages(List<MessagesDef> messages) {
//         this.messages = messages;
//     }
// 
//     class MessageHeader {
//         @SerializedName("X-User-ID")
//         private Long userId;
//         @SerializedName("X-Employee-ID")
//         private Long employeeId;
//         @SerializedName("X-Tenant-ID")
//         private Long tenantId;
// 
//         public Long getUserId() {
//             return userId;
//         }
// 
//         public void setUserId(Long userId) {
//             this.userId = userId;
//         }
// 
//         public Long getEmployeeId() {
//             return employeeId;
//         }
// 
//         public void setEmployeeId(Long employeeId) {
//             this.employeeId = employeeId;
//         }
// 
//         public Long getTenantId() {
//             return tenantId;
//         }
// 
//         public void setTenantId(Long tenantId) {
//             this.tenantId = tenantId;
//         }
// 
//         @Override
//         public String toString() {
//             return "MessageHeader{" +
//                     "userId=" + userId +
//                     ", employeeId=" + employeeId +
//                     ", tenantId=" + tenantId +
//                     '}';
//         }
//     }
// }


import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import initdata.publish.model.Messages;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

package initdata.publish;



/**
 * Created by I311352 on 11/23/2016.
 */

@Service
public class MessagePublishService {
    private static final Logger logger = Logger.getLogger(MessagePublishService.class);
    private static final String EXCHANGE_NAME = "light-model-batch";
    private static boolean USE_DEFAULT = true;

    private static final String DEFAULT_RABBIT_PROPERTIES= "/rabbit/rabbitmq.properties";
    private static final String DEFAULT_MESSAGE_SOURCE = "/messages/source.json";

    private Channel channel;
    private String rabbitProperties;
    private String messageSource;

    public MessagePublishService() {
        this.rabbitProperties = DEFAULT_RABBIT_PROPERTIES;
        this.messageSource = DEFAULT_MESSAGE_SOURCE;
    }

    public void publish() {
        logger.info("Publish Configuration: rabbit.cfg:" + this.rabbitProperties +
                " message source: " + this.messageSource);
        if (!createChannel()) {
            logger.error("Channel Create Failed, Do Nothing");
            return;
        }
        logger.info("Creaet RabbitMQ Channel Success, Start to publish message");
        try {

// Path: generatedata/src/main/java/initdata/publish/model/Messages.java
// public class Messages {
//     private Map<String, String> messageHeader;
//     private List<MessagesDef> messages;
//     public Map<String, String> getMessageHeader() {
//         return messageHeader;
//     }
// 
//     public void setMessageHeader(Map<String, String> messageHeader) {
//         this.messageHeader = messageHeader;
//     }
// 
//     public List<MessagesDef> getMessages() {
//         return messages;
//     }
// 
//     public void setMessages(List<MessagesDef> messages) {
//         this.messages = messages;
//     }
// 
//     class MessageHeader {
//         @SerializedName("X-User-ID")
//         private Long userId;
//         @SerializedName("X-Employee-ID")
//         private Long employeeId;
//         @SerializedName("X-Tenant-ID")
//         private Long tenantId;
// 
//         public Long getUserId() {
//             return userId;
//         }
// 
//         public void setUserId(Long userId) {
//             this.userId = userId;
//         }
// 
//         public Long getEmployeeId() {
//             return employeeId;
//         }
// 
//         public void setEmployeeId(Long employeeId) {
//             this.employeeId = employeeId;
//         }
// 
//         public Long getTenantId() {
//             return tenantId;
//         }
// 
//         public void setTenantId(Long tenantId) {
//             this.tenantId = tenantId;
//         }
// 
//         @Override
//         public String toString() {
//             return "MessageHeader{" +
//                     "userId=" + userId +
//                     ", employeeId=" + employeeId +
//                     ", tenantId=" + tenantId +
//                     '}';
//         }
//     }
// }


// Path: generatedata/src/main/java/initdata/publish/MessagePublishService.java
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import initdata.publish.model.Messages;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

package initdata.publish;



/**
 * Created by I311352 on 11/23/2016.
 */

@Service
public class MessagePublishService {
    private static final Logger logger = Logger.getLogger(MessagePublishService.class);
    private static final String EXCHANGE_NAME = "light-model-batch";
    private static boolean USE_DEFAULT = true;

    private static final String DEFAULT_RABBIT_PROPERTIES= "/rabbit/rabbitmq.properties";
    private static final String DEFAULT_MESSAGE_SOURCE = "/messages/source.json";

    private Channel channel;
    private String rabbitProperties;
    private String messageSource;

    public MessagePublishService() {
        this.rabbitProperties = DEFAULT_RABBIT_PROPERTIES;
        this.messageSource = DEFAULT_MESSAGE_SOURCE;
    }

    public void publish() {
        logger.info("Publish Configuration: rabbit.cfg:" + this.rabbitProperties +
                " message source: " + this.messageSource);
        if (!createChannel()) {
            logger.error("Channel Create Failed, Do Nothing");
            return;
        }
        logger.info("Creaet RabbitMQ Channel Success, Start to publish message");
        try {

            Messages messages = loadMessages();
