Package com.swiftmq.swiftlet.queue
Class QueueInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.swiftmq.swiftlet.queue.QueueInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class QueueInputStream extends java.io.InputStreamA QueueInputStream is an input stream that is mapped to a queue. Together with aQueueOutputStream, it enables queue based streaming.- Author:
- IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
- See Also:
QueueOutputStream
-
-
Constructor Summary
Constructors Constructor Description QueueInputStream(QueueReceiver queueReceiver, long receiveTimeout, int windowSize)Constructs a new QueueInputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.voidclose()Closes this input stream and releases any system resources associated with the stream.java.lang.ObjectgetMsgProp(java.lang.String key)Returns a message property.java.util.EnumerationgetMsgPropNames()Returns the names of the message properties.longgetReceiveTimeout()Returns the receive timeout.intgetWindowSize()Returns the window size.intread()Reads the next byte of data from the input stream.voidsetReceiveTimeout(long receiveTimeout)Set recive timeout.voidsetWindowSize(int windowSize)Sets the window size.
-
-
-
Constructor Detail
-
QueueInputStream
public QueueInputStream(QueueReceiver queueReceiver, long receiveTimeout, int windowSize)
Constructs a new QueueInputStream. The queue receiver works as factory for transactions (every message read from the queue is wrapped in a single transaction). The receive timeout ensures that a receive doesn't block forever. If a timeout occurs, it will be turned into an IOException of theread()method. The window size specifies a backlog of messages to receive, if messages are out of sequence. If the size is reached and the stream is still out of sequence, an IOException will be thrown.- Parameters:
queueReceiver- receiver.receiveTimeout- timeout.windowSize- window size.
-
-
Method Detail
-
getReceiveTimeout
public long getReceiveTimeout()
Returns the receive timeout.- Returns:
- receive timeout.
-
setReceiveTimeout
public void setReceiveTimeout(long receiveTimeout)
Set recive timeout.- Parameters:
receiveTimeout- receive timeout.
-
getWindowSize
public int getWindowSize()
Returns the window size.- Returns:
- window size.
-
setWindowSize
public void setWindowSize(int windowSize)
Sets the window size.- Parameters:
windowSize- window size.
-
getMsgPropNames
public java.util.Enumeration getMsgPropNames() throws java.lang.ExceptionReturns the names of the message properties.- Returns:
- names.
- Throws:
java.lang.Exception- on error.
-
getMsgProp
public java.lang.Object getMsgProp(java.lang.String key) throws java.lang.ExceptionReturns a message property.- Parameters:
key- key.- Returns:
- value.
- Throws:
java.lang.Exception- on error.
-
read
public int read() throws java.io.IOExceptionReads the next byte of data from the input stream. The value byte is returned as anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Specified by:
readin classjava.io.InputStream- Returns:
- the next byte of data, or
-1if the end of the stream is reached. - Throws:
java.io.IOException- if an I/O error occurs.
-
available
public int available() throws java.io.IOExceptionReturns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or or another thread.- Overrides:
availablein classjava.io.InputStream- Returns:
- the number of bytes that can be read from this input stream without blocking.
- Throws:
java.io.IOException- if an I/O error occurs.
-
close
public void close() throws java.io.IOExceptionCloses this input stream and releases any system resources associated with the stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- if an I/O error occurs.
-
-