use of org.apache.qpid.proton.engine.Sender in project activemq-artemis by apache.
the class AmqpSecurityTest method testConsumerNotAuthorizedToCreateQueues.
@Test(timeout = 30000)
public void testConsumerNotAuthorizedToCreateQueues() throws Exception {
AmqpClient client = createAmqpClient(noprivUser, noprivPass);
client.setValidator(new AmqpValidator() {
@Override
public void inspectOpenedResource(Sender sender) {
ErrorCondition condition = sender.getRemoteCondition();
if (condition != null && condition.getCondition() != null) {
if (!condition.getCondition().equals(AmqpError.UNAUTHORIZED_ACCESS)) {
markAsInvalid("Should have been tagged with unauthorized access error");
}
} else {
markAsInvalid("Sender should have been opened with an error");
}
}
});
AmqpConnection connection = client.connect();
try {
AmqpSession session = connection.createSession();
try {
session.createReceiver(getQueueName(getPrecreatedQueueSize() + 1));
fail("Should not be able to consume here.");
} catch (Exception ex) {
IntegrationTestLogger.LOGGER.info("Caught expected exception");
}
connection.getStateInspector().assertValid();
} finally {
connection.close();
}
}
use of org.apache.qpid.proton.engine.Sender in project activemq-artemis by apache.
the class AmqpSenderTest method testUnsettledSender.
@Test(timeout = 60000)
public void testUnsettledSender() throws Exception {
final int MSG_COUNT = 1000;
final CountDownLatch settled = new CountDownLatch(MSG_COUNT);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
connection.setStateInspector(new AmqpValidator() {
@Override
public void inspectDeliveryUpdate(Sender sender, Delivery delivery) {
if (delivery.remotelySettled()) {
IntegrationTestLogger.LOGGER.trace("Remote settled message for sender: " + sender.getName());
settled.countDown();
}
}
});
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(getQueueName(), false);
for (int i = 1; i <= MSG_COUNT; ++i) {
AmqpMessage message = new AmqpMessage();
message.setText("Test-Message: " + i);
sender.send(message);
if (i % 1000 == 0) {
IntegrationTestLogger.LOGGER.info("Sent message: " + i);
}
}
Queue queueView = getProxyToQueue(getQueueName());
Wait.assertTrue("All messages should arrive", () -> queueView.getMessageCount() == MSG_COUNT);
sender.close();
assertTrue("Remote should have settled all deliveries", settled.await(5, TimeUnit.MINUTES));
connection.close();
}
use of org.apache.qpid.proton.engine.Sender in project activemq-artemis by apache.
the class AMQPConnectionContext method remoteLinkOpened.
protected void remoteLinkOpened(Link link) throws Exception {
AMQPSessionContext protonSession = getSessionExtension(link.getSession());
link.setSource(link.getRemoteSource());
link.setTarget(link.getRemoteTarget());
if (link instanceof Receiver) {
Receiver receiver = (Receiver) link;
if (link.getRemoteTarget() instanceof Coordinator) {
Coordinator coordinator = (Coordinator) link.getRemoteTarget();
protonSession.addTransactionHandler(coordinator, receiver);
} else {
protonSession.addReceiver(receiver);
}
} else {
Sender sender = (Sender) link;
protonSession.addSender(sender);
}
}
use of org.apache.qpid.proton.engine.Sender in project azure-service-bus-java by Azure.
the class SendLinkHandler method onLinkRemoteOpen.
@Override
public void onLinkRemoteOpen(Event event) {
Link link = event.getLink();
if (link != null && link instanceof Sender) {
Sender sender = (Sender) link;
if (link.getRemoteTarget() != null) {
TRACE_LOGGER.debug("onLinkRemoteOpen: linkName:{}, remoteTarge:{}", sender.getName(), link.getRemoteTarget());
synchronized (this.firstFlow) {
this.isFirstFlow = false;
this.msgSender.onOpenComplete(null);
}
} else {
TRACE_LOGGER.debug("onLinkRemoteOpen: linkName:{}, remoteTarget:{}, remoteSource:{}, action:{}", sender.getName(), null, null, "waitingForError");
}
}
}
use of org.apache.qpid.proton.engine.Sender in project azure-service-bus-java by Azure.
the class SendLinkHandler method onDelivery.
@Override
public void onDelivery(Event event) {
Delivery delivery = event.getDelivery();
while (delivery != null) {
Sender sender = (Sender) delivery.getLink();
TRACE_LOGGER.debug("onDelivery: linkName:{}, unsettled:{}, credit:{}, deliveryState:{}, delivery.isBuffered:{}, delivery.tag:{}", sender.getName(), sender.getUnsettled(), sender.getRemoteCredit(), delivery.getRemoteState(), delivery.isBuffered(), delivery.getTag());
msgSender.onSendComplete(delivery);
delivery.settle();
delivery = sender.current();
}
}
Aggregations