Last active
October 13, 2018 12:02
-
-
Save akhilvijayan05/09dd26a140cc9cd2da511bcc1ae17932 to your computer and use it in GitHub Desktop.
A simple example for an AMPS subscriber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.crankuptheamps.client.Client; | |
import com.crankuptheamps.client.exception.AMPSException; | |
import scala.collection.JavaConverters._ | |
object Subscriber extends App { | |
val client = new Client("subscribe") | |
try { | |
client.connect("tcp://127.0.0.1:9007/amps/json") | |
client.logon() | |
val messageStream = client.subscribe("messages").iterator().asScala | |
messageStream.foreach(message => println(message.getData)) | |
} catch { | |
case ampsException: AMPSException => println(s"Caught exception: ${ampsException.getMessage}") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment