Package com.swiftmq.swiftlet.queue
Class QueueInputStream
java.lang.Object
java.io.InputStream
com.swiftmq.swiftlet.queue.QueueInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
A QueueInputStream is an input stream that is mapped to a queue. Together with
a
QueueOutputStream
, it enables queue based streaming.- Author:
- IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionQueueInputStream
(QueueReceiver queueReceiver, long receiveTimeout, int windowSize) Constructs a new QueueInputStream. -
Method Summary
Modifier and TypeMethodDescriptionint
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.void
close()
Closes this input stream and releases any system resources associated with the stream.getMsgProp
(String key) Returns a message property.Returns the names of the message properties.long
Returns the receive timeout.int
Returns the window size.int
read()
Reads the next byte of data from the input stream.void
setReceiveTimeout
(long receiveTimeout) Set recive timeout.void
setWindowSize
(int windowSize) Sets the window size.Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
QueueInputStream
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 Details
-
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
Returns the names of the message properties.- Returns:
- names.
- Throws:
Exception
- on error.
-
getMsgProp
Returns a message property.- Parameters:
key
- key.- Returns:
- value.
- Throws:
Exception
- on error.
-
read
Reads the next byte of data from the input stream. The value byte is returned as anint
in the range0
to255
. If no byte is available because the end of the stream has been reached, the value-1
is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Specified by:
read
in classInputStream
- Returns:
- the next byte of data, or
-1
if the end of the stream is reached. - Throws:
IOException
- if an I/O error occurs.
-
available
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. The next caller might be the same thread or or another thread.- Overrides:
available
in classInputStream
- Returns:
- the number of bytes that can be read from this input stream without blocking.
- Throws:
IOException
- if an I/O error occurs.
-
close
Closes this input stream and releases any system resources associated with the stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
- if an I/O error occurs.
-