Package org.apache.qpid.proton.engine

# Interface Receiver

All Superinterfaces:
  `Endpoint`, `Extendable`, `Link`

All Known Implementing Classes:
  `ReceiverImpl`

public interface Receiver extends Link
Receiver

## Method Summary

Modifier and Type
Method
Description
`boolean`
`advance()`
Attempts to advance the current delivery.
`void`
`drain(int credit)`
`boolean`
`draining()`
`void`
`flow(int credits)`
Adds the specified number of credits.
`ReadableBuffer`
`recv()`
Receive message data for the current delivery returning the data in a Readable buffer.
`int`
`recv(byte[] bytes, int offset, int size)`
Receive message data for the current delivery.
`int`
`recv(WritableBuffer buffer)`
Receive message data for the current delivery.
`void`
`setDrain(boolean drain)`

### Methods inherited from interface org.apache.qpid.proton.engine.Endpoint

`close, free, getCondition, getContext, getLocalState, getRemoteCondition, getRemoteState, open, setCondition, setContext`

### Methods inherited from interface org.apache.qpid.proton.engine.Extendable

`attachments`

### Methods inherited from interface org.apache.qpid.proton.engine.Link

`current, delivery, delivery, detach, detached, drained, getCredit, getDesiredCapabilities, getDrain, getMaxMessageSize, getName, getOfferedCapabilities, getProperties, getQueued, getReceiverSettleMode, getRemoteCredit, getRemoteDesiredCapabilities, getRemoteMaxMessageSize, getRemoteOfferedCapabilities, getRemoteProperties, getRemoteReceiverSettleMode, getRemoteSenderSettleMode, getRemoteSource, getRemoteTarget, getSenderSettleMode, getSession, getSource, getTarget, getUnsettled, head, next, setDesiredCapabilities, setMaxMessageSize, setOfferedCapabilities, setProperties, setReceiverSettleMode, setRemoteSenderSettleMode, setSenderSettleMode, setSource, setTarget`

## Method Details

### flow

void flow(int credits)
Adds the specified number of credits. The number of link credits initialises to zero. It is the application's responsibility to call this method to allow the receiver to receive `credits` more deliveries.

### recv

int recv(byte[] bytes, int offset, int size)
Receive message data for the current delivery. If the caller takes all the bytes the Receiver currently has for this delivery then it is removed from the Connection's work list. Before considering a delivery to be complete, the caller should examine `Delivery.isPartial()`. If the delivery is partial, the caller should call `recv(byte[], int, int)` again to receive the additional bytes once the Delivery appears again on the Connection work-list. TODO might the flags other than IO_WORK in DeliveryImpl also prevent the work list being pruned? e.g. what if a slow JMS consumer receives a disposition frame containing state=RELEASED? This is not IO_WORK.

Parameters:
  `bytes` - the destination array where the message data is written
  `offset` - index in the array to start writing data at
  `size` - the maximum number of bytes to write
Returns:
  number of bytes written. -1 if there are no more bytes for the current delivery.
See Also:
  - `Link.current()`

### recv

int recv(WritableBuffer buffer)
Receive message data for the current delivery.

Parameters:
  `buffer` - the buffer to write the message data.
Returns:
  number of bytes written. -1 if there are no more bytes for the current delivery.

### recv

ReadableBuffer recv()
Receive message data for the current delivery returning the data in a Readable buffer. The delivery will return an empty buffer if there is no pending data to be read or if all data has been read either by a previous call to this method or by a call to one of the other receive methods.

Returns:
  a ReadableBuffer that contains the currently available data for the current delivery.

### drain

void drain(int credit)

### advance

boolean advance()
Attempts to advance the current delivery. Advances it to the next delivery if one exists, else null. The behaviour of this method is different for senders and receivers. TODO document what this method conceptually does and when you should use it.

Specified by:
  `advance` in interface `Link`
Returns:
  true if it can advance, false if it cannot TODO document the meaning of the return value more fully. Currently Senderimpl only returns false if there is no current delivery

### draining

boolean draining()

### setDrain

void setDrain(boolean drain)