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.InputStream
A 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 int
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.void
close()
Closes this input stream and releases any system resources associated with the stream.java.lang.Object
getMsgProp(java.lang.String key)
Returns a message property.java.util.Enumeration
getMsgPropNames()
Returns the names of the message properties.long
getReceiveTimeout()
Returns the receive timeout.int
getWindowSize()
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.
-
-
-
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.Exception
Returns 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.Exception
Returns a message property.- Parameters:
key
- key.- Returns:
- value.
- Throws:
java.lang.Exception
- on error.
-
read
public int read() throws java.io.IOException
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 classjava.io.InputStream
- Returns:
- the next byte of data, or
-1
if the end of the stream is reached. - Throws:
java.io.IOException
- if an I/O error occurs.
-
available
public int available() throws java.io.IOException
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 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.IOException
Closes this input stream and releases any system resources associated with the stream.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
- if an I/O error occurs.
-
-