/** * 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); } }
properties.put(Symbol.getSymbol(TransportUtils.versionIdentifierKey), TransportUtils.USER_AGENT_STRING); 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); }
sender.setSource(senderSource); sender.setSenderSettleMode(SenderSettleMode.SETTLED); sender.setProperties(commonLinkProperties); SendLinkHandler sendLinkHandler = new SendLinkHandler(this.amqpSender); BaseHandler.setHandler(sender, sendLinkHandler);
sender.setProperties(properties);
this.senderLink.setProperties(this.getAmqpProperties());