use of org.apache.qpid.server.message.RoutingResult in project qpid-broker-j by apache.
the class QueueEntryImpl method routeToAlternate.
@Override
public int routeToAlternate(final Action<? super MessageInstance> action, ServerTransaction txn) {
if (!isAcquired()) {
throw new IllegalStateException("Illegal queue entry state. " + this + " is not acquired.");
}
final Queue<?> currentQueue = getQueue();
MessageDestination alternateBindingDestination = currentQueue.getAlternateBindingDestination();
boolean autocommit = txn == null;
if (autocommit) {
txn = new LocalTransaction(getQueue().getVirtualHost().getMessageStore());
}
RoutingResult result;
if (alternateBindingDestination != null) {
result = alternateBindingDestination.route(getMessage(), getMessage().getInitialRoutingAddress(), getInstanceProperties());
} else {
result = new RoutingResult<>(getMessage());
}
txn.dequeue(getEnqueueRecord(), new ServerTransaction.Action() {
@Override
public void postCommit() {
delete();
}
@Override
public void onRollback() {
}
});
int enqueues = result.send(txn, null);
if (autocommit) {
txn.commit();
}
return enqueues;
}
use of org.apache.qpid.server.message.RoutingResult in project qpid-broker-j by apache.
the class AbstractQueueTestBase method testRingOverflowPolicyMessagesRejected.
public void testRingOverflowPolicyMessagesRejected() {
Map<String, Object> attributes = new HashMap<>(_arguments);
attributes.put(Queue.OVERFLOW_POLICY, OverflowPolicy.RING);
attributes.put(Queue.MAXIMUM_QUEUE_DEPTH_MESSAGES, 0);
Queue<?> queue = getQueue();
queue.setAttributes(attributes);
ServerMessage message;
RoutingResult result;
message = createMessage(new Long(27), 20, 10);
result = queue.route(message, message.getInitialRoutingAddress(), null);
assertTrue("Result should include not accepting route", result.isRejected());
int headerSize = 20;
int payloadSize = 10;
int id = 28;
attributes = new HashMap<>(_arguments);
attributes.put(Queue.MAXIMUM_QUEUE_DEPTH_MESSAGES, 10);
attributes.put(Queue.MAXIMUM_QUEUE_DEPTH_BYTES, 10);
queue.setAttributes(attributes);
message = createMessage(new Long(id), headerSize, payloadSize);
result = queue.route(message, message.getInitialRoutingAddress(), null);
assertTrue("Result should include not accepting route", result.isRejected());
}
Aggregations