Search in sources :

Example 11 with Link

use of org.apache.qpid.proton.engine.Link in project azure-service-bus-java by Azure.

the class ReceiveLinkHandler method onLinkRemoteOpen.

@Override
public void onLinkRemoteOpen(Event event) {
    Link link = event.getLink();
    if (link != null && link instanceof Receiver) {
        Receiver receiver = (Receiver) link;
        if (link.getRemoteSource() != null) {
            TRACE_LOGGER.debug("onLinkRemoteOpen: linkName:{}, remoteSource:{}", receiver.getName(), receiver.getRemoteSource());
            synchronized (this.firstResponse) {
                this.isFirstResponse = false;
                this.amqpReceiver.onOpenComplete(null);
            }
        } else {
            TRACE_LOGGER.debug("onLinkRemoteOpen: linkName:{}, remoteTarget:{}, remoteTarget:{}, action:{}", receiver.getName(), null, null, "waitingForError");
        }
    }
}
Also used : Receiver(org.apache.qpid.proton.engine.Receiver) Link(org.apache.qpid.proton.engine.Link)

Example 12 with Link

use of org.apache.qpid.proton.engine.Link in project azure-service-bus-java by Azure.

the class ReceiveLinkHandler method onLinkLocalOpen.

@Override
public void onLinkLocalOpen(Event evt) {
    Link link = evt.getLink();
    if (link instanceof Receiver) {
        Receiver receiver = (Receiver) link;
        TRACE_LOGGER.debug("onLinkLocalOpen: linkName:{}, localSource:{}", receiver.getName(), receiver.getSource());
    }
}
Also used : Receiver(org.apache.qpid.proton.engine.Receiver) Link(org.apache.qpid.proton.engine.Link)

Example 13 with Link

use of org.apache.qpid.proton.engine.Link in project azure-service-bus-java by Azure.

the class MessagingFactory method closeConnection.

// One of the parameters must be null
private void closeConnection(ErrorCondition error, Exception cause) {
    // Important to copy the reference of the connection as a call to getConnection might create a new connection while we are still in this method
    Connection currentConnection = this.connection;
    if (currentConnection != null) {
        Link[] links = this.registeredLinks.toArray(new Link[0]);
        this.registeredLinks.clear();
        TRACE_LOGGER.debug("Closing all links on the connection. Number of links '{}'", links.length);
        for (Link link : links) {
            link.close();
        }
        TRACE_LOGGER.debug("Closed all links on the connection. Number of links '{}'", links.length);
        if (currentConnection.getLocalState() != EndpointState.CLOSED) {
            TRACE_LOGGER.info("Closing connection to host");
            currentConnection.close();
        }
        for (Link link : links) {
            Handler handler = BaseHandler.getHandler(link);
            if (handler != null && handler instanceof BaseLinkHandler) {
                BaseLinkHandler linkHandler = (BaseLinkHandler) handler;
                if (error != null) {
                    linkHandler.processOnClose(link, error);
                } else {
                    linkHandler.processOnClose(link, cause);
                }
            }
        }
    }
}
Also used : Connection(org.apache.qpid.proton.engine.Connection) BaseHandler(org.apache.qpid.proton.engine.BaseHandler) Handler(org.apache.qpid.proton.engine.Handler) Link(org.apache.qpid.proton.engine.Link)

Aggregations

Link (org.apache.qpid.proton.engine.Link)13 Target (org.apache.qpid.proton.amqp.messaging.Target)2 Receiver (org.apache.qpid.proton.engine.Receiver)2 Source (org.apache.qpid.proton.amqp.messaging.Source)1 BaseHandler (org.apache.qpid.proton.engine.BaseHandler)1 Connection (org.apache.qpid.proton.engine.Connection)1 Handler (org.apache.qpid.proton.engine.Handler)1 Sender (org.apache.qpid.proton.engine.Sender)1