Package org.apache.qpid.proton.engine.impl

# Class ReceiverImpl

java.lang.Object
org.apache.qpid.proton.engine.impl.EndpointImpl
org.apache.qpid.proton.engine.impl.LinkImpl
org.apache.qpid.proton.engine.impl.ReceiverImpl

All Implemented Interfaces:
  `Endpoint`, `Extendable`, `Link`, `ProtonJEndpoint`, `Receiver`

public class ReceiverImpl extends LinkImpl implements 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.
`int`
`getRemoteCredit()`
Returns a [locally generated] view of credit at the remote peer by considering the current link `credit` count as well as the effect of any locally `queued` messages.
`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 class org.apache.qpid.proton.engine.impl.LinkImpl

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

### Methods inherited from class org.apache.qpid.proton.engine.impl.EndpointImpl

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

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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, 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

### advance

public boolean advance()
Description copied from interface: `Link`
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.

Specified by:
  `advance` in interface `Link`
Specified by:
  `advance` in interface `Receiver`
Overrides:
  `advance` in class `LinkImpl`
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

### flow

public void flow(int credits)
Description copied from interface: `Receiver`
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.

Specified by:
  `flow` in interface `Receiver`

### recv

public int recv(byte[] bytes, int offset, int size)
Description copied from interface: `Receiver`
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 `Receiver.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.

Specified by:
  `recv` in interface `Receiver`
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

public int recv(WritableBuffer buffer)
Description copied from interface: `Receiver`
Receive message data for the current delivery.

Specified by:
  `recv` in interface `Receiver`
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

public ReadableBuffer recv()
Description copied from interface: `Receiver`
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.

Specified by:
  `recv` in interface `Receiver`
Returns:
  a ReadableBuffer that contains the currently available data for the current delivery.

### drain

public void drain(int credit)

Specified by:
  `drain` in interface `Receiver`

### draining

public boolean draining()

Specified by:
  `draining` in interface `Receiver`

### setDrain

public void setDrain(boolean drain)

Specified by:
  `setDrain` in interface `Receiver`

### getRemoteCredit

public int getRemoteCredit()
Description copied from interface: `Link`
Returns a [locally generated] view of credit at the remote peer by considering the current link `credit` count as well as the effect of any locally `queued` messages.

Specified by:
  `getRemoteCredit` in interface `Link`
Returns:
  view of effective remote credit