@Override protected boolean isClosePending() { // When no link terminus was created, the peer will now detach/close us otherwise // we need to validate the returned remote source prior to open completion. return getEndpoint().getRemoteTarget() == null; }
@Override public String getAddress() { return sender.getRemoteTarget().getAddress(); } }
@Override protected boolean isClosePending() { // When no link terminus was created, the peer will now detach/close us otherwise // we need to validate the returned remote source prior to open completion. return getEndpoint().getRemoteTarget() == null; } }
@Override protected boolean isClosePending() { // When no link terminus was created, the peer will now detach/close us otherwise // we need to validate the returned remote source prior to open completion. return getEndpoint().getRemoteTarget() == null; } }
@Override protected boolean isClosePending() { // When no link terminus was created, the peer will now detach/close us otherwise // we need to validate the returned remote source prior to open completion. return getEndpoint().getRemoteTarget() == null; }
@Override protected boolean isClosePending() { // When no link terminus was created, the peer will now detach/close us otherwise // we need to validate the returned remote source prior to open completion. return getEndpoint().getRemoteTarget() == null; }
@Override protected boolean isClosePending() { // When no link terminus was created, the peer will now detach/close us otherwise // we need to validate the returned remote source prior to open completion. return getEndpoint().getRemoteTarget() == null; }
@Override protected void doOpenCompletion() { // Verify the attach response contained a non-null target org.apache.qpid.proton.amqp.transport.Target t = getEndpoint().getRemoteTarget(); if (t != null) { super.doOpenCompletion(); } else { // No link terminus was created, the peer will now detach/close us. } }
@Override protected Exception getOpenAbortException() { // Verify the attach response contained a non-null target org.apache.qpid.proton.amqp.transport.Target t = getEndpoint().getRemoteTarget(); if (t != null) { return super.getOpenAbortException(); } else { // No link terminus was created, the peer has detach/closed us, create IDE. return new InvalidDestinationException("Link creation was refused"); } }
@Override protected Exception getOpenAbortException() { // Verify the attach response contained a non-null target org.apache.qpid.proton.amqp.transport.Target target = getEndpoint().getRemoteTarget(); if (target != null) { return super.getOpenAbortException(); } else { // No link terminus was created, the peer has detach/closed us, create IDE. return new InvalidDestinationException("Link creation was refused"); } } }
@Override protected Exception getOpenAbortException() { // Verify the attach response contained a non-null target org.apache.qpid.proton.amqp.transport.Target target = getEndpoint().getRemoteTarget(); if (target != null) { return super.getOpenAbortException(); } else { // No link terminus was created, the peer has detach/closed us, create IDE. return new InvalidDestinationException("Link creation was refused"); } } }
@Override protected void afterOpened() { if (!isClosePending()) { // Once our sender is opened we can read the updated name from the target address. String oldDestinationName = resourceInfo.getAddress(); String destinationName = getEndpoint().getRemoteTarget().getAddress(); resourceInfo.setAddress(destinationName); LOG.trace("Updated temp destination to: {} from: {}", destinationName, oldDestinationName); } } }
@Override protected void afterOpened() { if (!isClosePending()) { // Once our sender is opened we can read the updated name from the target address. String oldDestinationName = resourceInfo.getAddress(); String destinationName = getEndpoint().getRemoteTarget().getAddress(); resourceInfo.setAddress(destinationName); LOG.trace("Updated temp destination to: {} from: {}", destinationName, oldDestinationName); } } }
protected void doTestCreateDynamicSenderAndPublish(boolean topic) throws Exception { Target target = createDynamicTarget(topic); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); AmqpSender sender = session.createSender(target); assertNotNull(sender); Target remoteTarget = (Target) sender.getEndpoint().getRemoteTarget(); Queue queueView = getProxyToQueue(remoteTarget.getAddress()); assertNotNull(queueView); // Get the new address String address = sender.getSender().getRemoteTarget().getAddress(); LOG.info("New dynamic sender address -> {}", address); // Create a message and send to a receive that is listening on the newly // created dynamic link address. AmqpMessage message = new AmqpMessage(); message.setMessageId("msg-1"); message.setText("Test-Message"); AmqpReceiver receiver = session.createReceiver(address); receiver.flow(1); sender.send(message); AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS); assertNotNull("Should have read a message", received); received.accept(); receiver.close(); sender.close(); connection.close(); }
@SuppressWarnings("unchecked") protected void doTestCreateDynamicSender(boolean topic) throws Exception { Target target = createDynamicTarget(topic); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); AmqpSender sender = session.createSender(target); assertNotNull(sender); Target remoteTarget = (Target) sender.getEndpoint().getRemoteTarget(); assertTrue(remoteTarget.getDynamic()); assertTrue(remoteTarget.getDurable().equals(TerminusDurability.NONE)); assertTrue(remoteTarget.getExpiryPolicy().equals(TerminusExpiryPolicy.LINK_DETACH)); // Check the dynamic node lifetime-policy Map<Symbol, Object> dynamicNodeProperties = remoteTarget.getDynamicNodeProperties(); assertTrue(dynamicNodeProperties.containsKey(LIFETIME_POLICY)); assertEquals(DeleteOnClose.getInstance(), dynamicNodeProperties.get(LIFETIME_POLICY)); Queue queueView = getProxyToQueue(remoteTarget.getAddress()); assertNotNull(queueView); connection.close(); }
protected void doTestDynamicSenderLifetimeBoundToLinkQueue(boolean topic) throws Exception { Target target = createDynamicTarget(topic); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); AmqpSender sender = session.createSender(target); assertNotNull(sender); Target remoteTarget = (Target) sender.getEndpoint().getRemoteTarget(); Queue queueView = getProxyToQueue(remoteTarget.getAddress()); assertNotNull(queueView); sender.close(); queueView = getProxyToQueue(remoteTarget.getAddress()); assertNull(queueView); connection.close(); }