// Path: src/com/newlandframework/avatarmq/msg/ProducerAckMessage.java
// public class ProducerAckMessage extends BaseMessage implements Serializable {
// 
//     private String ack;
//     private int status;
//     private String msgId;
// 
//     public String getAck() {
//         return ack;
//     }
// 
//     public void setAck(String ack) {
//         this.ack = ack;
//     }
// 
//     public int getStatus() {
//         return status;
//     }
// 
//     public void setStatus(int status) {
//         this.status = status;
//     }
// 
//     public String getMsgId() {
//         return msgId;
//     }
// 
//     public void setMsgId(String msgId) {
//         this.msgId = msgId;
//     }
// }
// 
// Path: src/com/newlandframework/avatarmq/core/CallBackInvoker.java
// public class CallBackInvoker<T> {
// 
//     private final CountDownLatch countDownLatch = new CountDownLatch(1);
//     private T messageResult;
//     private List<CallBackListener<T>> listeners = Collections.synchronizedList(new ArrayList<CallBackListener<T>>());
//     private String requestId;
//     private Throwable reason;
// 
//     public void setReason(Throwable reason) {
//         this.reason = reason;
//         publish();
//         countDownLatch.countDown();
//     }
// 
//     public String getRequestId() {
//         return requestId;
//     }
// 
//     public void setRequestId(String requestId) {
//         this.requestId = requestId;
//     }
// 
//     public CallBackInvoker() {
//     }
// 
//     public void setMessageResult(T messageResult) {
//         this.messageResult = messageResult;
//         publish();
//         countDownLatch.countDown();
//     }
// 
//     public Object getMessageResult(long timeout, TimeUnit unit) {
//         try {
//             countDownLatch.await(timeout, unit);
//         } catch (InterruptedException e) {
//             throw new RuntimeException();
//         }
//         if (reason != null) {
//             return null;
//         }
//         return messageResult;
//     }
// 
//     public void join(CallBackListener<T> listener) {
//         this.listeners.add(listener);
//     }
// 
//     private void publish() {
//         for (CallBackListener<T> listener : listeners) {
//             listener.onCallBack(messageResult);
//         }
//     }
// }
// 
// Path: src/com/newlandframework/avatarmq/core/CallBackListener.java
// public interface CallBackListener<T> {
// 
//     void onCallBack(T t);
// 
// }
// 
// Path: src/com/newlandframework/avatarmq/core/NotifyCallback.java
// public interface NotifyCallback {
// 
//     void onEvent(ProducerAckMessage result);
// }
// 
// Path: src/com/newlandframework/avatarmq/model/RequestMessage.java
// public class RequestMessage extends BusinessMessage {
// 
//     public RequestMessage() {
//         super();
//     }
// }
// 
// Path: src/com/newlandframework/avatarmq/model/ResponseMessage.java
// public class ResponseMessage extends BusinessMessage {
// 
//     public ResponseMessage() {
//         super();
//     }
// }


import com.newlandframework.avatarmq.msg.ProducerAckMessage;
import com.newlandframework.avatarmq.core.CallBackInvoker;
import com.newlandframework.avatarmq.core.CallBackListener;
import com.newlandframework.avatarmq.core.NotifyCallback;
import com.newlandframework.avatarmq.model.RequestMessage;
import com.newlandframework.avatarmq.model.ResponseMessage;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
            return;
        }

        Map<String, CallBackInvoker<Object>> callBackMap = factory.getCallBackMap();

        CallBackInvoker<Object> invoker = new CallBackInvoker<Object>();
        callBackMap.put(request.getMsgId(), invoker);

        invoker.setRequestId(request.getMsgId());

        invoker.join(new CallBackListener<Object>() {
            public void onCallBack(Object t) {
                ResponseMessage response = (ResponseMessage) t;
                listener.onEvent((ProducerAckMessage) response.getMsgParams());

            }
        });

        ChannelFuture channelFuture = channel.writeAndFlush(request);
        channelFuture.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future) throws Exception {
                if (!future.isSuccess()) {
                    invoker.setReason(future.cause());
                }
            }
        });

    }

    public Object sendAsynMessage(RequestMessage request) {
// Path: src/com/newlandframework/avatarmq/msg/ProducerAckMessage.java
// public class ProducerAckMessage extends BaseMessage implements Serializable {
// 
//     private String ack;
//     private int status;
//     private String msgId;
// 
//     public String getAck() {
//         return ack;
//     }
// 
//     public void setAck(String ack) {
//         this.ack = ack;
//     }
// 
//     public int getStatus() {
//         return status;
//     }
// 
//     public void setStatus(int status) {
//         this.status = status;
//     }
// 
//     public String getMsgId() {
//         return msgId;
//     }
// 
//     public void setMsgId(String msgId) {
//         this.msgId = msgId;
//     }
// }
// 
// Path: src/com/newlandframework/avatarmq/core/CallBackInvoker.java
// public class CallBackInvoker<T> {
// 
//     private final CountDownLatch countDownLatch = new CountDownLatch(1);
//     private T messageResult;
//     private List<CallBackListener<T>> listeners = Collections.synchronizedList(new ArrayList<CallBackListener<T>>());
//     private String requestId;
//     private Throwable reason;
// 
//     public void setReason(Throwable reason) {
//         this.reason = reason;
//         publish();
//         countDownLatch.countDown();
//     }
// 
//     public String getRequestId() {
//         return requestId;
//     }
// 
//     public void setRequestId(String requestId) {
//         this.requestId = requestId;
//     }
// 
//     public CallBackInvoker() {
//     }
// 
//     public void setMessageResult(T messageResult) {
//         this.messageResult = messageResult;
//         publish();
//         countDownLatch.countDown();
//     }
// 
//     public Object getMessageResult(long timeout, TimeUnit unit) {
//         try {
//             countDownLatch.await(timeout, unit);
//         } catch (InterruptedException e) {
//             throw new RuntimeException();
//         }
//         if (reason != null) {
//             return null;
//         }
//         return messageResult;
//     }
// 
//     public void join(CallBackListener<T> listener) {
//         this.listeners.add(listener);
//     }
// 
//     private void publish() {
//         for (CallBackListener<T> listener : listeners) {
//             listener.onCallBack(messageResult);
//         }
//     }
// }
// 
// Path: src/com/newlandframework/avatarmq/core/CallBackListener.java
// public interface CallBackListener<T> {
// 
//     void onCallBack(T t);
// 
// }
// 
// Path: src/com/newlandframework/avatarmq/core/NotifyCallback.java
// public interface NotifyCallback {
// 
//     void onEvent(ProducerAckMessage result);
// }
// 
// Path: src/com/newlandframework/avatarmq/model/RequestMessage.java
// public class RequestMessage extends BusinessMessage {
// 
//     public RequestMessage() {
//         super();
//     }
// }
// 
// Path: src/com/newlandframework/avatarmq/model/ResponseMessage.java
// public class ResponseMessage extends BusinessMessage {
// 
//     public ResponseMessage() {
//         super();
//     }
// }


// Path: src/com/newlandframework/avatarmq/netty/MessageProcessor.java
import com.newlandframework.avatarmq.msg.ProducerAckMessage;
import com.newlandframework.avatarmq.core.CallBackInvoker;
import com.newlandframework.avatarmq.core.CallBackListener;
import com.newlandframework.avatarmq.core.NotifyCallback;
import com.newlandframework.avatarmq.model.RequestMessage;
import com.newlandframework.avatarmq.model.ResponseMessage;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

            return;
        }

        Map<String, CallBackInvoker<Object>> callBackMap = factory.getCallBackMap();

        CallBackInvoker<Object> invoker = new CallBackInvoker<Object>();
        callBackMap.put(request.getMsgId(), invoker);

        invoker.setRequestId(request.getMsgId());

        invoker.join(new CallBackListener<Object>() {
            public void onCallBack(Object t) {
                ResponseMessage response = (ResponseMessage) t;
                listener.onEvent((ProducerAckMessage) response.getMsgParams());

            }
        });

        ChannelFuture channelFuture = channel.writeAndFlush(request);
        channelFuture.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future) throws Exception {
                if (!future.isSuccess()) {
                    invoker.setReason(future.cause());
                }
            }
        });

    }

    public Object sendAsynMessage(RequestMessage request) {
        Channel channel = factory.getMessageChannel();