public Sender create(Session session) { return session.sender(_path); } }
/** * Open the Session links for session * @param session the {@link Session} endpoint. * @throws IOException if the function failed to open the links for the provided session. * @throws IllegalArgumentException if the session is {@code null}. */ public void openLinks(Session session) throws IOException, IllegalArgumentException { if (session == null) { throw new IllegalArgumentException("The session cannot be null."); } try { this.receiverLink = session.receiver(this.receiverLinkTag); this.receiverLink.setProperties(this.amqpProperties); this.receiverLink.open(); this.senderLink = session.sender(this.senderLinkTag); this.senderLink.setProperties(this.amqpProperties); this.senderLink.open(); } catch (Exception e) { throw new IOException("Proton exception", e); } }
Sender snd = ssn.sender(SEND_TAG); snd.setProperties(properties);
/** * Event handler for the connection init event * @param event The Proton Event object. */ @Override public void onConnectionInit(Event event) { // Codes_SRS_AMQPSIOTHUBCONNECTION_15_025: [The event handler shall get the Connection (Proton) object from the event handler and set the host name on the connection.] this.connection = event.getConnection(); this.connection.setHostname(this.hostName); // Codes_SRS_AMQPSIOTHUBCONNECTION_15_026: [The event handler shall create a Session (Proton) object from the connection.] this.session = this.connection.session(); // Codes_SRS_AMQPSIOTHUBCONNECTION_15_027: [The event handler shall create a Receiver and Sender (Proton) links and set the protocol tag on them to a predefined constant.] this.receiver = this.session.receiver(receiveTag); this.sender = this.session.sender(sendTag); // Codes_SRS_AMQPSIOTHUBCONNECTION_15_028: [The Receiver and Sender links shall have the properties set to client version identifier.] Map<Symbol, Object> properties = new HashMap<>(); properties.put(Symbol.getSymbol(versionIdentifierKey), TransportUtils.javaDeviceClientIdentifier + TransportUtils.clientVersion); this.receiver.setProperties(properties); this.sender.setProperties(properties); // Codes_SRS_AMQPSIOTHUBCONNECTION_15_029: [The event handler shall open the connection, session, sender and receiver objects.] this.connection.open(); this.session.open(); receiver.open(); sender.open(); }
private void createSendLink(SenderLinkSettings linkSettings) { TRACE_LOGGER.info("Creating send link to '{}'", this.sendPath); final Connection connection = this.underlyingFactory.getConnection(); final Session session = connection.session(); session.setOutgoingWindow(Integer.MAX_VALUE); session.open(); BaseHandler.setHandler(session, new SessionHandler(sendPath)); final Sender sender = session.sender(linkSettings.linkName); sender.setTarget(linkSettings.target); sender.setSource(linkSettings.source); sender.setProperties(linkSettings.linkProperties); TRACE_LOGGER.debug("Send link settle mode '{}'", linkSettings.settleMode); sender.setSenderSettleMode(linkSettings.settleMode); SendLinkHandler handler = new SendLinkHandler(CoreMessageSender.this); BaseHandler.setHandler(sender, handler); sender.open(); this.sendLink = sender; this.underlyingFactory.registerForConnectionError(this.sendLink); }
public RequestResponseChannel( final String linkName, final String path, final Session session) { this.replyTo = path.replace("$", "") + "-client-reply-to"; this.openRefCount = new AtomicInteger(2); this.closeRefCount = new AtomicInteger(2); this.inflightRequests = new HashMap<>(); this.requestId = new AtomicLong(0); this.sendLink = session.sender(linkName + ":sender"); final Target target = new Target(); target.setAddress(path); this.sendLink.setTarget(target); sendLink.setSource(new Source()); this.sendLink.setSenderSettleMode(SenderSettleMode.SETTLED); BaseHandler.setHandler(this.sendLink, new SendLinkHandler(new RequestHandler())); this.receiveLink = session.receiver(linkName + ":receiver"); final Source source = new Source(); source.setAddress(path); this.receiveLink.setSource(source); final Target receiverTarget = new Target(); receiverTarget.setAddress(this.replyTo); this.receiveLink.setTarget(receiverTarget); this.receiveLink.setSenderSettleMode(SenderSettleMode.SETTLED); this.receiveLink.setReceiverSettleMode(ReceiverSettleMode.SECOND); BaseHandler.setHandler(this.receiveLink, new ReceiveLinkHandler(new ResponseHandler())); }
public Sender create(Session session) { Sender sender = session.sender(_path); Target target = new Target(); target.setAddress(_path); sender.setTarget(target); // the C implemenation does this: Source source = new Source(); source.setAddress(_path); sender.setSource(source); if (getOutgoingWindow() > 0) { // use explicit settlement via dispositions (not pre-settled) sender.setSenderSettleMode(SenderSettleMode.UNSETTLED); sender.setReceiverSettleMode(ReceiverSettleMode.SECOND); // desired } return sender; } }
public Sender create(Session session) { Sender sender = session.sender(_path); Target target = new Target(); target.setAddress(_path); sender.setTarget(target); // the C implemenation does this: Source source = new Source(); source.setAddress(_path); sender.setSource(source); if (getOutgoingWindow() > 0) { // use explicit settlement via dispositions (not pre-settled) sender.setSenderSettleMode(SenderSettleMode.UNSETTLED); sender.setReceiverSettleMode(ReceiverSettleMode.SECOND); // desired } return sender; } }
private void createSender(org.apache.qpid.proton.engine.Session session) throws Exception { Sender sender = session.sender(subscriberInfo.getClientId()); Target target = new Target(); target.setAddress(subscriberInfo.getClientAddress()); sender.setTarget(target); Source source = new Source(); source.setAddress(subscriberInfo.getClientAddress()); source.setDurable(TerminusDurability.UNSETTLED_STATE); sender.setSource(source); sender.open(); } }
final String senderName = "Dynamic-" + UUID.randomUUID().toString(); Sender sender = session.sender(senderName); sender.setSenderSettleMode(SenderSettleMode.SETTLED);
@Override protected void doOpen() { Coordinator coordinator = new Coordinator(); coordinator.setCapabilities(TxnCapability.LOCAL_TXN); Source source = new Source(); String coordinatorName = "qpid-jms:coordinator:" + session.getConnection().getConnectionId(); Sender sender = session.getEndpoint().sender(coordinatorName); sender.setSource(source); sender.setTarget(coordinator); sender.setSenderSettleMode(SenderSettleMode.UNSETTLED); sender.setReceiverSettleMode(ReceiverSettleMode.FIRST); setEndpoint(sender); super.doOpen(); }
@Override public ProtonSender createSender(String address, ProtonLinkOptions senderOptions) { Sender sender = session.sender(getOrCreateLinkName(senderOptions));
Sender sender = getParent().getEndpoint().sender(senderLinkName); sender.setSource(source); sender.setTarget(target);
@Override protected Sender createEndpoint(JmsSessionInfo resourceInfo) { Coordinator coordinator = new Coordinator(); coordinator.setCapabilities(TxnCapability.LOCAL_TXN); Symbol[] outcomes = new Symbol[]{ Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL, Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL }; Source source = new Source(); source.setOutcomes(outcomes); String coordinatorName = "qpid-jms:coordinator:" + resourceInfo.getId().toString(); Sender sender = getParent().getSession().getEndpoint().sender(coordinatorName); sender.setSource(source); sender.setTarget(coordinator); sender.setSenderSettleMode(SenderSettleMode.UNSETTLED); sender.setReceiverSettleMode(ReceiverSettleMode.FIRST); return sender; }
@Override protected Sender createEndpoint(JmsSessionInfo resourceInfo) { Coordinator coordinator = new Coordinator(); coordinator.setCapabilities(TxnCapability.LOCAL_TXN); Symbol[] outcomes = new Symbol[]{ Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL, Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL }; Source source = new Source(); source.setOutcomes(outcomes); String coordinatorName = "qpid-jms:coordinator:" + resourceInfo.getId().toString(); Sender sender = getParent().getSession().getEndpoint().sender(coordinatorName); sender.setSource(source); sender.setTarget(coordinator); sender.setSenderSettleMode(SenderSettleMode.UNSETTLED); sender.setReceiverSettleMode(ReceiverSettleMode.FIRST); return sender; }
@Override public AMQPClientSenderContext createSender(String address, boolean preSettled) throws ActiveMQAMQPException { FutureRunnable futureRunnable = new FutureRunnable(1); ProtonClientContext amqpSender; synchronized (connection.getLock()) { Sender sender = session.sender(address); sender.setSenderSettleMode(SenderSettleMode.SETTLED); Target target = new Target(); target.setAddress(address); sender.setTarget(target); amqpSender = new ProtonClientContext(connection, sender, this, sessionSPI); amqpSender.afterInit(futureRunnable); sender.setContext(amqpSender); sender.open(); } connection.flush(); waitWithTimeout(futureRunnable); return amqpSender; }
Sender sender = getParent().getEndpoint().sender(senderLinkName); sender.setSource(source); sender.setTarget(target);
@Override public void accept(Session session) { if (MessageSender.this.getIsClosingOrClosed()) { session.close(); return; } final Sender sender = session.sender(TrackingUtil.getLinkName(session)); final Target target = new Target(); target.setAddress(sendPath); sender.setTarget(target); final Source source = new Source(); sender.setSource(source); sender.setSenderSettleMode(SenderSettleMode.UNSETTLED); final SendLinkHandler handler = new SendLinkHandler(MessageSender.this); BaseHandler.setHandler(sender, handler); if (MessageSender.this.sendLink != null) { MessageSender.this.underlyingFactory.deregisterForConnectionError(MessageSender.this.sendLink); } MessageSender.this.underlyingFactory.registerForConnectionError(sender); sender.open(); synchronized (MessageSender.this.errorConditionLock) { MessageSender.this.sendLink = sender; } } };
Sender sender = session.getEndpoint().sender(senderName); sender.setSource(source); sender.setTarget(target);
Sender sender = getParent().getEndpoint().sender(senderName); sender.setSource(source); sender.setTarget(target);