public class MessageEnumerator
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
MessageEnumerator.MessageListener
An interface used to notify a listener when messages are received.
|
Constructor and Description |
---|
MessageEnumerator(oracle.iot.client.enterprise.EnterpriseClient client)
Creates a message enumerator to retrieve messages.
|
Modifier and Type | Method and Description |
---|---|
oracle.iot.client.enterprise.Pageable<Message> |
getMessages(java.lang.String deviceID,
Message.Type type,
boolean expand,
long since,
long until)
Returns a list of messages stored by cloud service matching the given query criteria.
|
void |
setListener(java.lang.String deviceId,
Message.Type type,
MessageEnumerator.MessageListener listener)
Set a listener that gets notified when a message is received from the specified device.
|
public MessageEnumerator(oracle.iot.client.enterprise.EnterpriseClient client)
client
- the client to use to retrieve messagesjava.lang.NullPointerException
- if the client is null
public oracle.iot.client.enterprise.Pageable<Message> getMessages(java.lang.String deviceID, Message.Type type, boolean expand, long since, long until) throws java.io.IOException, java.security.GeneralSecurityException
The query criteria can be based on either a specific device or a specific type of message. The messages are always returned in descending order of message received-time (for messages sent by the device) or message sent-time (for messages sent to the device) as recorded by the cloud service.
The efficiency of this method depends on the number
of messages being accessed. If the deviceId
parameter is null,
messages from any device matching the streams configured for the
enterprise integration will be listed. Streams determine which kinds
of data messages and alerts will be processed and used by an
enterprise integration. The greater the number of devices in the
stream, the greater the potential impact on the efficiency of this
method. Consider using MessageIterator
, which gives greater
control over the message enumeration parameters, when accessing
messages for all devices in a stream.
The efficiency of this method also depends on
the type of messages being accessed. If the type
parameter
is null, all message types are enumerated.
Consider using MessageIterator
, which gives greater
control over the message enumeration parameters, when accessing
messages for all message types in a stream.
By default, the Pageable
will contain at most 10 messages.
This can be configured by setting the property
oracle.iot.client.enterprise.message_enumerator_limit
to an
integer value between 10 and 200, inclusive.
deviceID
- the identifier of the device to get messages.
If null
, messages coming from any device are listed.type
- the type of messages to enumerate
If null
, all message types are enumerated.expand
- indicates that messages should include the message
payload along with core message properties.since
- Epoch time in milliseconds used to retrieve the messages
with message recorded time (either received-time or sent-time) by the
cloud service that is greater than or equal to this time. If the
value is 0 the parameter is ignored.until
- Epoch time in milliseconds used to retrieve the messages
with message recorded time (either received-time or sent-time) by the
cloud service that is less than this time. If the value is 0
the parameter is ignored.Iterable
of Message
java.io.IOException
- if request for messages failedjava.security.GeneralSecurityException
- when key or signature algorithm class
cannot be loaded, or the key is not in
the trusted assets store, or the
private key is invalid. If User Authentication is used,
then UserAuthenticationException
will be thrown
if the session cookie has expired.public void setListener(java.lang.String deviceId, Message.Type type, MessageEnumerator.MessageListener listener) throws java.lang.IllegalStateException, java.io.IOException, java.security.GeneralSecurityException
null
, the method removes the listener for this device.
Only one listener can be set per device.
This method calls the MessagePoller.setListener
API.
The MessagePoller
sends a query to the server once every 3000 milliseconds.
This can be configured with the
com.oracle.iot.client.enterprise.message_polling_interval
property.
By default, the MessagePoller
returns 10 messages per query.
This can be configured with the
com.oracle.iot.client.enterprise.message_polling_limit
property.
The value for this property may be between 10 and 200, inclusive.
The efficiency of the MessagePoller
depends on the number
of messages being accessed. If the deviceId
parameter is null,
messages from any device matching the streams configured for the
enterprise integration will be listed. Streams determine which kinds
of data messages and alerts will be processed and used by an
enterprise integration. The greater the number of devices in the
stream, the greater the potential impact on the efficiency of this
method.
deviceId
- the device to listen.
If null
, messages coming from any device are listened.type
- the type of messages to listen.
If null
, all message types are listened.listener
- the listener to notify when a message is received.
If null
, removes the listener for the specified device.java.lang.IllegalStateException
- if an listener has already been set for this devicejava.io.IOException
- if request for the time of the last message failedjava.security.GeneralSecurityException
- when key or signature algorithm class
cannot be loaded, or the key is not in
the trusted assets store, or the
private key is invalid. If User Authentication is used,
then UserAuthenticationException
will be thrown
if the session cookie has expired.