001
014
015 package com.liferay.portal.kernel.messaging;
016
017 import com.liferay.portal.kernel.util.StackTraceUtil;
018 import com.liferay.portal.kernel.util.StringBundler;
019
020 import java.io.Serializable;
021
022
025 public class MessageStatus implements Serializable {
026
027 public long getDuration() {
028 return _endTime - _startTime;
029 }
030
031 public String getExceptionMessage() {
032 return _exceptionMessage;
033 }
034
035 public String getExceptionStackTrace() {
036 return _exceptionStackTrace;
037 }
038
039 public Object getPayload() {
040 return _payload;
041 }
042
043 public boolean hasException() {
044 if (_exceptionStackTrace != null) {
045 return true;
046 }
047 else {
048 return false;
049 }
050 }
051
052 public void setException(Exception e) {
053 _exceptionMessage = e.getMessage();
054 _exceptionStackTrace = StackTraceUtil.getStackTrace(e);
055 }
056
057 public void setPayload(Object payload) {
058 _payload = payload;
059 }
060
061 public void startTimer() {
062 _startTime = System.currentTimeMillis();
063 }
064
065 public void stopTimer() {
066 _endTime = System.currentTimeMillis();
067 }
068
069 @Override
070 public String toString() {
071 StringBundler sb = new StringBundler(11);
072
073 sb.append("{startTime=");
074 sb.append(_startTime);
075 sb.append(", endTime=");
076 sb.append(_endTime);
077 sb.append(", payload=");
078 sb.append(_payload);
079 sb.append(", errorMessage=");
080 sb.append(_exceptionMessage);
081 sb.append(", errorStackTrace=");
082 sb.append(_exceptionStackTrace);
083 sb.append("}");
084
085 return sb.toString();
086 }
087
088 private long _endTime;
089 private String _exceptionMessage;
090 private String _exceptionStackTrace;
091 private Object _payload;
092 private long _startTime;
093
094 }