String address = remoteTarget.getAddress() ; if (address == null) { address = msg.getAddress();
private static boolean matchTarget(Target target, String path) { if (target == null) return path.isEmpty(); else return path.equals(target.getAddress()); }
private static boolean matchTarget(Target target, String path) { if (target == null) return path.isEmpty(); else return path.equals(target.getAddress()); }
private static boolean matchTarget(Target target, String path) { if (target == null) return path.isEmpty(); else return path.equals(target.getAddress()); }
/** * Create a new sender instance using the given Target when creating the link. * * @param session * The parent session that created the session. * @param target * The target that this sender produces to. * @param senderId * The unique ID assigned to this sender. */ public AmqpSender(AmqpSession session, Target target, String senderId) { if (target == null) { throw new IllegalArgumentException("User specified Target cannot be null"); } this.session = session; this.address = target.getAddress(); this.senderId = senderId; this.userSpecifiedTarget = target; this.userSpecifiedSenderSettlementMode = null; this.userSpecifiedReceiverSettlementMode = null; }
@Override public String toString() { return "Target{" + "address='" + getAddress() + '\'' + ", durable=" + getDurable() + ", expiryPolicy=" + getExpiryPolicy() + ", timeout=" + getTimeout() + ", dynamic=" + getDynamic() + ", dynamicNodeProperties=" + getDynamicNodeProperties() + ", capabilities=" + (getCapabilities() == null ? null : Arrays.asList(getCapabilities())) + '}'; }
@Override public String toString() { return "Target{" + "address='" + getAddress() + '\'' + ", durable=" + getDurable() + ", expiryPolicy=" + getExpiryPolicy() + ", timeout=" + getTimeout() + ", dynamic=" + getDynamic() + ", dynamicNodeProperties=" + getDynamicNodeProperties() + ", capabilities=" + (getCapabilities() == null ? null : Arrays.asList(getCapabilities())) + '}'; }
@Override public String toString() { return "Target{" + "address='" + getAddress() + '\'' + ", durable=" + getDurable() + ", expiryPolicy=" + getExpiryPolicy() + ", timeout=" + getTimeout() + ", dynamic=" + getDynamic() + ", dynamicNodeProperties=" + getDynamicNodeProperties() + ", capabilities=" + (getCapabilities() == null ? null : Arrays.asList(getCapabilities())) + '}'; } }
@Override public void close(boolean remoteLinkClose) throws ActiveMQAMQPException { protonSession.removeReceiver(receiver); org.apache.qpid.proton.amqp.messaging.Target target = (org.apache.qpid.proton.amqp.messaging.Target) receiver.getRemoteTarget(); if (target != null && target.getDynamic() && (target.getExpiryPolicy() == TerminusExpiryPolicy.LINK_DETACH || target.getExpiryPolicy() == TerminusExpiryPolicy.SESSION_END)) { try { sessionSPI.removeTemporaryQueue(SimpleString.toSimpleString(target.getAddress())); } catch (Exception e) { //ignore on close, its temp anyway and will be removed later } } }
@Override public void close(boolean remoteLinkClose) throws ActiveMQAMQPException { protonSession.removeReceiver(receiver); org.apache.qpid.proton.amqp.messaging.Target target = (org.apache.qpid.proton.amqp.messaging.Target) receiver.getRemoteTarget(); if (target != null && target.getDynamic() && (target.getExpiryPolicy() == TerminusExpiryPolicy.LINK_DETACH || target.getExpiryPolicy() == TerminusExpiryPolicy.SESSION_END)) { try { sessionSPI.removeTemporaryQueue(SimpleString.toSimpleString(target.getAddress())); } catch (Exception e) { //ignore on close, its temp anyway and will be removed later } } }
public Object get(final int index) { switch(index) { case 0: return _impl.getAddress(); case 1: return _impl.getDurable().getValue(); case 2: return _impl.getExpiryPolicy().getPolicy(); case 3: return _impl.getTimeout(); case 4: return _impl.getDynamic(); case 5: return _impl.getDynamicNodeProperties(); case 6: return _impl.getCapabilities(); } throw new IllegalStateException("Unknown index " + index); }
public Object get(final int index) { switch(index) { case 0: return _impl.getAddress(); case 1: return _impl.getDurable().getValue(); case 2: return _impl.getExpiryPolicy().getPolicy(); case 3: return _impl.getTimeout(); case 4: return _impl.getDynamic(); case 5: return _impl.getDynamicNodeProperties(); case 6: return _impl.getCapabilities(); } throw new IllegalStateException("Unknown index " + index); }
public Object get(final int index) { switch(index) { case 0: return _impl.getAddress(); case 1: return _impl.getDurable().getValue(); case 2: return _impl.getExpiryPolicy().getPolicy(); case 3: return _impl.getTimeout(); case 4: return _impl.getDynamic(); case 5: return _impl.getDynamicNodeProperties(); case 6: return _impl.getCapabilities(); } throw new IllegalStateException("Unknown index " + index); }
public Object get(final int index) { switch(index) { case 0: return _impl.getAddress(); case 1: return _impl.getDurable().getValue(); case 2: return _impl.getExpiryPolicy().getPolicy(); case 3: return _impl.getTimeout(); case 4: return _impl.getDynamic(); case 5: return _impl.getDynamicNodeProperties(); case 6: return _impl.getCapabilities(); } throw new IllegalStateException("Unknown index " + index); }
@Override public void connectionOpened(ProtonConnection connection) { ProtonSender sender = connection.createSender(linkOptions.getTarget().getAddress()); sender.setTarget(linkOptions.getTarget()); sender.setQoS(clientOptions.getQos()); sender.openHandler(result -> { if (result.succeeded()) { log.info("Sender link '" + sender.getTarget().getAddress() + "' opened, sending messages"); connectPromise.complete(null); sendNext(connection, sender); } else { handleError(connection, sender.getRemoteCondition()); } }); sender.closeHandler(result -> handleError(connection, sender.getRemoteCondition())); sender.open(); }
public int size() { return _impl.getCapabilities() != null ? 7 : _impl.getDynamicNodeProperties() != null ? 6 : _impl.getDynamic() ? 5 : (_impl.getTimeout() != null && !_impl.getTimeout().equals(UnsignedInteger.ZERO)) ? 4 : !_impl.getExpiryPolicy().equals(TerminusExpiryPolicy.SESSION_END) ? 3 : !_impl.getDurable().equals(TerminusDurability.NONE) ? 2 : _impl.getAddress() != null ? 1 : 0; } }
public int size() { return _impl.getCapabilities() != null ? 7 : _impl.getDynamicNodeProperties() != null ? 6 : _impl.getDynamic() ? 5 : (_impl.getTimeout() != null && !_impl.getTimeout().equals(UnsignedInteger.ZERO)) ? 4 : !_impl.getExpiryPolicy().equals(TerminusExpiryPolicy.SESSION_END) ? 3 : !_impl.getDurable().equals(TerminusDurability.NONE) ? 2 : _impl.getAddress() != null ? 1 : 0; } }
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(); }
@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 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(); }