public class TokenPublisher
extends java.lang.Object
The batch is sent it out periodically according to the period parameter.
Red (ahuseyno) |
Red (ahuseyno) |
Constructor and Description |
---|
TokenPublisher(long period,
ProxyModelInfrastructure proxyModelInfrastructure)
Create instance of the TokenPublisher with specified period and tokensPerPeriod.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancel the publisher's timer used for sending batch of tokens.
|
com.ibm.mqtt.IMqttClient |
getMqttClient()
Return MQTT client that is used to send out MQTT messages.
|
java.lang.String |
getTopic()
Return the topic where the messages are published.
|
void |
sendToken(Token token,
ProxySink sender)
Send the token via MQTT protocol.
|
void |
setMqttClient(com.ibm.mqtt.IMqttClient mqttClient)
Set the mqttClient to be used to publish the tokens.
|
void |
setTopic(java.lang.String topic)
Set the topic for the message to publish.
|
void |
startTimer(Ticket ticket)
Start the timer that sends token batches.
|
public TokenPublisher(long period, ProxyModelInfrastructure proxyModelInfrastructure)
period
- The period in milliseconds between batchesproxyModelInfrastructure
- The infrastructure that created this listener and controls the state of the execution.public void startTimer(Ticket ticket)
ticket
- Ticket on which to start the publishing timer.public void cancel()
public com.ibm.mqtt.IMqttClient getMqttClient()
setMqttClient(IMqttClient)
public java.lang.String getTopic()
setTopic(String)
public void sendToken(Token token, ProxySink sender) throws IllegalActionException
The token will not be sent out immediately but would be batched for the specified period.
token
- The token to sendsender
- The sink that produced the token. If the parameter is null,
then the token was not produced by the model but programmatically i.e. for monitoring purposes.IllegalActionException
- if there is a problem with MQTT broker.public void setMqttClient(com.ibm.mqtt.IMqttClient mqttClient)
mqttClient
- the mqttClient to be used to publish the tokens.getMqttClient()
public void setTopic(java.lang.String topic)
topic
- the topic to publish the MQTT messages.getTopic()