if (sync && getStatus() != ExchangeStatus.ACTIVE) {
throw new MessagingException("illegal call to sendSync");
}
this.syncState = sync ? SYNC_STATE_SYNC_SENT : SYNC_STATE_ASYNC;
// Check status
ExchangeStatus status = getStatus();
if (status == ExchangeStatus.ACTIVE && !can(CAN_STATUS_ACTIVE)) {
throw new MessagingException("illegal exchange status: active");
}
if (status == ExchangeStatus.DONE && !can(CAN_STATUS_DONE)) {
throw new MessagingException("illegal exchange status: done");