- Scala 2.11.x
Add the following line to your sbt dependencies:
"com.github.vooolll" %% "scala-stomp-websocket-client" % "0.1.2"
Note: make sure that you have in your build.sbt
resolvers += Resolver.sonatypeRepo("releases")
- STOMP 1.1 without heartbeat
CONNECT
,SUBSCRIBE
,UNSUBSCRIBE
,DISCONNECT
,ERROR
frame handling- Custom WS endpoint and HTTP headers
- Integration with Play! Framework (no Netty-dependency issues because of standalone WS transport)
RECEIPT
frame andreceipe-id
headerACK
,NACK
,BEGIN
,COMMIT
,ABORT
frames- Custom heartbeat
object Main extends App {
val client = new MessageBrokerClient(
"ws://example.com/msgbroker/",
"login",
"passcode",
Map(
"My-Header" -> "123"
)
)
client.onConnect(_ => {
print("connected!")
client.subscribe("/topic/one/*", (msg) => {
println(s"received message! $msg")
client.unsubscribe("/topic/one/*")
client.disconnect()
})
}).onFailure({
case t: Throwable =>
println(s"failure! ${t.getMessage}")
case _ =>
// do nothing
}).onDisconnect(_ => {
println("disconnected!")
}).connect()
}