Detailed Description

Typedef Documentation

A pn_link_t object encapsulates all of the endpoint state associated with an AMQP Link. A pn_link_t object contains an ordered sequence of pn_delivery_t objects representing in-flight deliveries. A pn_link_t may be either sender or a receiver but never both.

A pn_link_t object maintains a pointer to the current delivery within the ordered sequence of deliveries contained by the link (See pn_link_current). The current delivery is the target of a number of operations associated with the link, such as sending (pn_link_send) and receiving (pn_link_recv) message data.

Whenever a link operation fails (i.e. returns an error code), additional error details can be obtained using this function. The error object that is returned may also be used to clear the error condition.

The pointer returned by this operation is valid until the link object is freed.

The pn_condition_t object retrieved may be modified prior to closing a link in order to indicate a particular condition exists when the link closes. This is normally used to communicate error conditions to the remote peer, however it may also be used in non error cases. See pn_condition_t for more details.

The pointer returned by this operation is valid until the link object is freed.

The pn_condition_t object retrieved may be examined in order to determine whether the remote peer was indicating some sort of exceptional condition when the remote link endpoint was closed. The pn_condition_t object returned may not be modified.

The pointer returned by this operation is valid until the link object is freed.

Examines the state of each link owned by the connection and returns the first link that matches the given state mask. If state contains both local and remote flags, then an exact match against those flags is performed. If state contains only local or only remote flags, then a match occurs if any of the local or remote flags are set respectively. state==0 matches all links.

Parameters

[in]

connection

to be searched for matching Links

[in]

state

mask to match

Returns

the first link owned by the connection that matches the mask, else NULL if no links match

Once this operation has completed, the PN_LOCAL_CLOSED state flag will be set. This may be called without calling pn_link_open, in this case it is equivalent to calling pn_link_open followed by pn_link_close.

Each link maintains a sequence of deliveries in the order they were created, along with a pointer to the current delivery. All send/recv operations on a link take place on the current delivery. If a link has no current delivery, the current delivery is automatically initialized to the next delivery created on the link. Once initialized, the current delivery remains the same until it is changed through use of pn_link_advance or until it is settled via pn_delivery_settle.

Advance the current delivery of a link to the next delivery on the link.

For sending links this operation is used to finish sending message data for the current outgoing delivery and move on to the next outgoing delivery (if any).

For receiving links, this operation is used to finish accessing message data from the current incoming delivery and move on to the next incoming delivery (if any).

Each link maintains a sequence of deliveries in the order they were created, along with a pointer to the current delivery. The pn_link_advance operation will modify the current delivery on the link to point to the next delivery in the sequence. If there is no next delivery in the sequence, the current delivery will be set to NULL. This operation will return true if invoking it caused the value of the current delivery to change, even if it was set to NULL.

Links use a credit based flow control scheme. Every receiver maintains a credit balance that corresponds to the number of deliveries that the receiver can accept at any given moment. As more capacity becomes available at the receiver (see pn_link_flow), it adds credit to this balance and communicates the new balance to the sender. Whenever a delivery is sent/received, the credit balance maintained by the link is decremented by one. Once the credit balance at the sender reaches zero, the sender must pause sending until more credit is obtained from the receiver.

Note that a sending link may still be used to send deliveries even if pn_link_credit reaches zero, however those deliveries will end up being buffered by the link until enough credit is obtained from the receiver to send them over the wire. In this case the balance reported by pn_link_credit will go negative.

Links may queue deliveries for a number of reasons, for example there may be insufficient credit to send them to the receiver (see pn_link_credit), or they simply may not have yet had a chance to be written to the wire. This operation will return the number of queued deliveries on a link.

If a link is in drain mode, then the sending endpoint of a link must immediately use up all available credit on the link. If this is not possible, the excess credit must be returned by invoking pn_link_drained. Only the receiving endpoint can set the drain mode. See pn_link_set_drain for details.

When a link is in drain mode, the sender must use all excess credit immediately, and release any excess credit back to the receiver if there are no deliveries available to send.

When invoked on a sending link that is in drain mode, this operation will release all excess credit back to the receiver and return the number of credits released back to the sender. If the link is not in drain mode, this operation is a noop.

When invoked on a receiving link, this operation will return and reset the number of credits the sender has released back to the receiver.

The available count for a link provides a hint as to the number of deliveries that might be able to be sent if sufficient credit were issued by the receiving link endpoint. See pn_link_offered for more details.

Note that the link API can be used to stream large messages across the network, so just because there is no data to read does not imply the message is complete. To ensure the entirety of the message data has been read, either invoke pn_link_recv until PN_EOS is returned, or verify that