| 1 |
/* |
| 2 |
* |
| 3 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 4 |
* or more contributor license agreements. See the NOTICE file |
| 5 |
* distributed with this work for additional information |
| 6 |
* regarding copyright ownership. The ASF licenses this file |
| 7 |
* to you under the Apache License, Version 2.0 (the |
| 8 |
* "License"); you may not use this file except in compliance |
| 9 |
* with the License. You may obtain a copy of the License at |
| 10 |
* |
| 11 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 12 |
* |
| 13 |
* Unless required by applicable law or agreed to in writing, |
| 14 |
* software distributed under the License is distributed on an |
| 15 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 |
* KIND, either express or implied. See the License for the |
| 17 |
* specific language governing permissions and limitations |
| 18 |
* under the License. |
| 19 |
* |
| 20 |
*/ |
| 21 |
package org.apache.qpid.proton.engine; |
| 22 |
|
| 23 |
import org.apache.qpid.proton.codec.ReadableBuffer; |
| 24 |
import org.apache.qpid.proton.codec.WritableBuffer; |
| 25 |
|
| 26 |
/** |
| 27 |
* Receiver |
| 28 |
* |
| 29 |
*/ |
| 30 |
public interface Receiver extends Link |
| 31 |
{ |
| 32 |
|
| 33 |
/** |
| 34 |
* Adds the specified number of credits. |
| 35 |
* |
| 36 |
* The number of link credits initialises to zero. It is the application's responsibility to call |
| 37 |
* this method to allow the receiver to receive {@code credits} more deliveries. |
| 38 |
*/ |
| 39 |
public void flow(int credits); |
| 40 |
|
| 41 |
/** |
| 42 |
* Receive message data for the current delivery. |
| 43 |
* |
| 44 |
* If the caller takes all the bytes the Receiver currently has for this delivery then it is removed from |
| 45 |
* the Connection's work list. |
| 46 |
* |
| 47 |
* Before considering a delivery to be complete, the caller should examine {@link Delivery#isPartial()}. If |
| 48 |
* the delivery is partial, the caller should call {@link #recv(byte[], int, int)} again to receive |
| 49 |
* the additional bytes once the Delivery appears again on the Connection work-list. |
| 50 |
* |
| 51 |
* TODO might the flags other than IO_WORK in DeliveryImpl also prevent the work list being pruned? |
| 52 |
* e.g. what if a slow JMS consumer receives a disposition frame containing state=RELEASED? This is not IO_WORK. |
| 53 |
* |
| 54 |
* @param bytes the destination array where the message data is written |
| 55 |
* @param offset index in the array to start writing data at |
| 56 |
* @param size the maximum number of bytes to write |
| 57 |
* |
| 58 |
* @return number of bytes written. -1 if there are no more bytes for the current delivery. |
| 59 |
* |
| 60 |
* @see #current() |
| 61 |
*/ |
| 62 |
public int recv(byte[] bytes, int offset, int size); |
| 63 |
|
| 64 |
/** |
| 65 |
* Receive message data for the current delivery. |
| 66 |
* |
| 67 |
* @param buffer the buffer to write the message data. |
| 68 |
* |
| 69 |
* @return number of bytes written. -1 if there are no more bytes for the current delivery. |
| 70 |
*/ |
| 71 |
public int recv(WritableBuffer buffer); |
| 72 |
|
| 73 |
/** |
| 74 |
* Receive message data for the current delivery returning the data in a Readable buffer. |
| 75 |
* |
| 76 |
* The delivery will return an empty buffer if there is no pending data to be read or if all |
| 77 |
* data has been read either by a previous call to this method or by a call to one of the other |
| 78 |
* receive methods. |
| 79 |
* |
| 80 |
* @return a ReadableBuffer that contains the currently available data for the current delivery. |
| 81 |
*/ |
| 82 |
public ReadableBuffer recv(); |
| 83 |
|
| 84 |
public void drain(int credit); |
| 85 |
|
| 86 |
/** |
| 87 |
* {@inheritDoc} |
| 88 |
* |
| 89 |
* TODO document what this method conceptually does and when you should use it. |
| 90 |
*/ |
| 91 |
@Override |
| 92 |
public boolean advance(); |
| 93 |
|
| 94 |
public boolean draining(); |
| 95 |
|
| 96 |
public void setDrain(boolean drain); |
| 97 |
|
| 98 |
} |