if(!sender.sendQueueFull()) { int msgNum = sent.incrementAndGet(); System.out.println("Sending message " + msgNum + " to client, for address: " + remoteSource.getAddress()); Message m = message("Hello " + msgNum + " from Server!"); sender.send(m, delivery -> {
private static boolean matchSource(Source source, String path) { if (source == null) return path.isEmpty(); else return path.equals(source.getAddress()); }
private static boolean matchSource(Source source, String path) { if (source == null) return path.isEmpty(); else return path.equals(source.getAddress()); }
private static boolean matchSource(Source source, String path) { if (source == null) return path.isEmpty(); else return path.equals(source.getAddress()); }
/** * Create a new receiver instance. * * @param session * The parent session that created the receiver. * @param source * The Source instance to use instead of creating and configuring one. * @param receiverId * The unique ID assigned to this receiver. */ public AmqpReceiver(AmqpSession session, Source source, String receiverId) { if (source == null) { throw new IllegalArgumentException("User specified Source cannot be null"); } this.session = session; this.address = source.getAddress(); this.receiverId = receiverId; this.userSpecifiedSource = source; this.userSpecifiedSenderSettlementMode = null; this.userSpecifiedReceiverSettlementMode = null; }
private boolean isPubSub(Source source) { String pubSubPrefix = sessionSPI.getPubSubPrefix(); return source != null && pubSubPrefix != null && source.getAddress() != null && source.getAddress().startsWith(pubSubPrefix); }
@Override public void close(boolean remoteLinkClose) throws ActiveMQAMQPException { super.close(remoteLinkClose); try { sessionSPI.closeSender(brokerConsumer); //if this is a link close rather than a connection close or detach, we need to delete any durable resources for // say pub subs if (remoteLinkClose ) { Source source = (Source)sender.getSource(); if (source != null && source.getAddress() != null && hasCapabilities(TOPIC, source)) { String address = source.getAddress(); boolean exists = sessionSPI.queueQuery(address); if (exists) { sessionSPI.deleteQueue(address); } } } } catch (Exception e) { log.warn(e.getMessage(), e); throw new ActiveMQAMQPInternalErrorException(e.getMessage()); } }
public ReceiverStatus recvMessages(Source source, Predicate<Message> done, Optional<String> linkName) { CompletableFuture<List<Message>> resultPromise = new CompletableFuture<>(); Vertx vertx = VertxFactory.create(); clients.add(vertx); String containerId = "systemtest-receiver-" + source.getAddress(); CompletableFuture<Void> connectPromise = new CompletableFuture<>(); Receiver receiver = new Receiver(options, done, new LinkOptions(source, new Target(), linkName), connectPromise, resultPromise, containerId); vertx.deployVerticle(receiver); try { connectPromise.get(2, TimeUnit.MINUTES); } catch (Exception e) { resultPromise.completeExceptionally(e); } return new ReceiverStatus() { @Override public Future<List<Message>> getResult() { return resultPromise; } @Override public int getNumReceived() { return receiver.getNumReceived(); } }; }
@Override public String toString() { return "Source{" + "address='" + getAddress() + '\'' + ", durable=" + getDurable() + ", expiryPolicy=" + getExpiryPolicy() + ", timeout=" + getTimeout() + ", dynamic=" + getDynamic() + ", dynamicNodeProperties=" + getDynamicNodeProperties() + ", distributionMode=" + _distributionMode + ", filter=" + _filter + ", defaultOutcome=" + _defaultOutcome + ", outcomes=" + (_outcomes == null ? null : Arrays.asList(_outcomes)) + ", capabilities=" + (getCapabilities() == null ? null : Arrays.asList(getCapabilities())) + '}'; }
@Override public String toString() { return "Source{" + "address='" + getAddress() + '\'' + ", durable=" + getDurable() + ", expiryPolicy=" + getExpiryPolicy() + ", timeout=" + getTimeout() + ", dynamic=" + getDynamic() + ", dynamicNodeProperties=" + getDynamicNodeProperties() + ", distributionMode=" + _distributionMode + ", filter=" + _filter + ", defaultOutcome=" + _defaultOutcome + ", outcomes=" + (_outcomes == null ? null : Arrays.asList(_outcomes)) + ", capabilities=" + (getCapabilities() == null ? null : Arrays.asList(getCapabilities())) + '}'; }
@Override public String toString() { return "Source{" + "address='" + getAddress() + '\'' + ", durable=" + getDurable() + ", expiryPolicy=" + getExpiryPolicy() + ", timeout=" + getTimeout() + ", dynamic=" + getDynamic() + ", dynamicNodeProperties=" + getDynamicNodeProperties() + ", distributionMode=" + _distributionMode + ", filter=" + _filter + ", defaultOutcome=" + _defaultOutcome + ", outcomes=" + (_outcomes == null ? null : Arrays.asList(_outcomes)) + ", capabilities=" + (getCapabilities() == null ? null : Arrays.asList(getCapabilities())) + '}'; } }
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.getDistributionMode(); case 7: return _impl.getFilter(); case 8: return _impl.getDefaultOutcome(); case 9: return _impl.getOutcomes(); case 10: 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.getDistributionMode(); case 7: return _impl.getFilter(); case 8: return _impl.getDefaultOutcome(); case 9: return _impl.getOutcomes(); case 10: 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.getDistributionMode(); case 7: return _impl.getFilter(); case 8: return _impl.getDefaultOutcome(); case 9: return _impl.getOutcomes(); case 10: 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.getDistributionMode(); case 7: return _impl.getFilter(); case 8: return _impl.getDefaultOutcome(); case 9: return _impl.getOutcomes(); case 10: return _impl.getCapabilities(); } throw new IllegalStateException("Unknown index " + index); }
public int size() { return _impl.getCapabilities() != null ? 11 : _impl.getOutcomes() != null ? 10 : _impl.getDefaultOutcome() != null ? 9 : _impl.getFilter() != null ? 8 : _impl.getDistributionMode() != null ? 7 : _impl.getDynamicNodeProperties() != null ? 6 : _impl.getDynamic() ? 5 : (_impl.getTimeout() != null && !_impl.getTimeout().equals(UnsignedInteger.ZERO)) ? 4 : _impl.getExpiryPolicy() != TerminusExpiryPolicy.SESSION_END ? 3 : _impl.getDurable() != TerminusDurability.NONE ? 2 : _impl.getAddress() != null ? 1 : 0; }
public int size() { return _impl.getCapabilities() != null ? 11 : _impl.getOutcomes() != null ? 10 : _impl.getDefaultOutcome() != null ? 9 : _impl.getFilter() != null ? 8 : _impl.getDistributionMode() != null ? 7 : _impl.getDynamicNodeProperties() != null ? 6 : _impl.getDynamic() ? 5 : (_impl.getTimeout() != null && !_impl.getTimeout().equals(UnsignedInteger.ZERO)) ? 4 : _impl.getExpiryPolicy() != TerminusExpiryPolicy.SESSION_END ? 3 : _impl.getDurable() != TerminusDurability.NONE ? 2 : _impl.getAddress() != null ? 1 : 0; }
protected void doTestDynamicReceiverLifetimeBoundToLinkQueue(boolean topic) throws Exception { Source source = createDynamicSource(topic); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createReceiver(source); assertNotNull(receiver); Source remoteSource = (Source) receiver.getEndpoint().getRemoteSource(); Queue queueView = getProxyToQueue(remoteSource.getAddress()); assertNotNull(queueView); receiver.close(); queueView = getProxyToQueue(remoteSource.getAddress()); assertNull(queueView); connection.close(); }
@SuppressWarnings("unchecked") protected void doTestCreateDynamicReceiver(boolean topic) throws Exception { Source source = createDynamicSource(topic); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createReceiver(source); assertNotNull(receiver); Source remoteSource = (Source) receiver.getEndpoint().getRemoteSource(); assertTrue(remoteSource.getDynamic()); assertTrue(remoteSource.getDurable().equals(TerminusDurability.NONE)); assertTrue(remoteSource.getExpiryPolicy().equals(TerminusExpiryPolicy.LINK_DETACH)); // Check the dynamic node lifetime-policy Map<Symbol, Object> dynamicNodeProperties = remoteSource.getDynamicNodeProperties(); assertTrue(dynamicNodeProperties.containsKey(LIFETIME_POLICY)); assertEquals(DeleteOnClose.getInstance(), dynamicNodeProperties.get(LIFETIME_POLICY)); Queue queueView = getProxyToQueue(remoteSource.getAddress()); assertNotNull(queueView); connection.close(); }
Queue queueView = getProxyToQueue(remoteSource.getAddress()); assertNotNull(queueView);