use of org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError in project qpid-broker-j by apache.
the class NodeReceivingDestination method send.
@Override
public void send(final ServerMessage<?> message, final ServerTransaction txn, final SecurityToken securityToken) throws UnroutableMessageException {
final String routingAddress = "".equals(_routingAddress) ? getRoutingAddress(message) : _routingAddress;
_destination.authorisePublish(securityToken, Collections.singletonMap("routingKey", routingAddress));
final InstanceProperties instanceProperties = new InstanceProperties() {
@Override
public Object getProperty(final Property prop) {
switch(prop) {
case MANDATORY:
return false;
case REDELIVERED:
return false;
case PERSISTENT:
return message.isPersistent();
case IMMEDIATE:
return false;
case EXPIRATION:
return message.getExpiration();
}
return null;
}
};
RoutingResult result = _destination.route(message, routingAddress, instanceProperties);
final int enqueues = result.send(txn, null);
if (enqueues == 0) {
if (!_discardUnroutable) {
final String errorMessage;
final AmqpError errorCode;
if (result.isRejected()) {
if (result.containsReject(RejectType.LIMIT_EXCEEDED)) {
errorCode = AmqpError.RESOURCE_LIMIT_EXCEEDED;
} else if (result.containsReject(RejectType.PRECONDITION_FAILED)) {
errorCode = AmqpError.PRECONDITION_FAILED;
} else {
errorCode = AmqpError.ILLEGAL_STATE;
}
errorMessage = result.getRejectReason();
} else {
errorCode = AmqpError.NOT_FOUND;
errorMessage = String.format("Unknown destination '%s'", routingAddress);
}
throw new UnroutableMessageException(errorCode, errorMessage);
} else {
_eventLogger.message(ExchangeMessages.DISCARDMSG(_destination.getName(), routingAddress));
}
}
}
Aggregations