stomp-for-akka-streams

Provide akka streams source, sink, and flow for connecting to STOMP PROTOCOL 1.2 server and clients

License

License

Categories

Categories

Akka Container Microservices Reactive libraries
GroupId

GroupId

com.nachinius
ArtifactId

ArtifactId

stomp-for-akka-streams_2.12
Last Version

Last Version

0.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

stomp-for-akka-streams
Provide akka streams source, sink, and flow for connecting to STOMP PROTOCOL 1.2 server and clients
Project URL

Project URL

https://github.com/nachinius/StompConnectorForAkkaStreams
Project Organization

Project Organization

com.nachinius
Source Code Management

Source Code Management

https://github.com/nachinius/StompConnectorForAkkaStreams

Download stomp-for-akka-streams_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.nachinius/stomp-for-akka-streams_2.12/ -->
<dependency>
    <groupId>com.nachinius</groupId>
    <artifactId>stomp-for-akka-streams_2.12</artifactId>
    <version>0.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.nachinius/stomp-for-akka-streams_2.12/
implementation 'com.nachinius:stomp-for-akka-streams_2.12:0.1.2'
// https://jarcasting.com/artifacts/com.nachinius/stomp-for-akka-streams_2.12/
implementation ("com.nachinius:stomp-for-akka-streams_2.12:0.1.2")
'com.nachinius:stomp-for-akka-streams_2.12:jar:0.1.2'
<dependency org="com.nachinius" name="stomp-for-akka-streams_2.12" rev="0.1.2">
  <artifact name="stomp-for-akka-streams_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.nachinius', module='stomp-for-akka-streams_2.12', version='0.1.2')
)
libraryDependencies += "com.nachinius" % "stomp-for-akka-streams_2.12" % "0.1.2"
[com.nachinius/stomp-for-akka-streams_2.12 "0.1.2"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.4
io.vertx : vertx-stomp jar 3.5.1
com.typesafe.akka : akka-stream_2.12 jar 2.5.9

test (2)

Group / Artifact Type Version
com.typesafe.akka : akka-stream-testkit_2.12 jar 2.5.9
org.scalatest : scalatest_2.12 jar 3.0.4

Project Modules

There are no modules declared in this project.

Latest version Build Status License codecov

STOMP Protocol Connector

The Stomp Protocol connector provides Akka Streams sources and sinks to connect to STOMP servers.

Reported issues

Tagged issues at Github

Usage

Connecting to a STOMP server

All the STOMP connectors are configured using a (com.nachinius.akka.stream.stomp.ConnectionProvider).

There are some types of (com.nachinius.akka.stream.stomp.ConnectionProvider):

  • LocalConnectionProvider which connects to the default localhost. It creates a new connection for each stage.
  • DetailsConnectionProvider which supports more fine-grained configuration. It creates a new connection for each stage.

Sinking messages into a STOMP server

Create the ConnectorSettings

 val host = "localhost"
           val port = 61613
           val topic = "AnyTopic"
           val settings =
 ConnectorSettings(connectionProvider = DetailsConnectionProvider(host, port), destination = Some(topic)))

StompClientSink is a collection of factory methods that facilitates creation of sinks.

Create a sink, that accepts and forwards SendingFrame to the STOMP server.

  val sinkToStomp: Sink[SendingFrame, Future[Done]] = StompClientSink(settings)

Last step is to materialize and run the sink we created.

  val input = Vector("one", "two")
  val source = Source(input).map(SendingFrame.from)
  val sinkDone = source.runWith(sinkToStomp)

Receiving messages from STOMP server using a StompClientSource

Create the [ConnectorSettings] that specifies the STOMP server to connect, and the STOMP destination that you want receive messages from

  val host = "localhost"
  val port = 61667
  val destination = "/topic/topic2"
  val settings = ConnectorSettings(DetailsConnectionProvider(host, port, None), Some(destination))ector-settings }

Create a source, that generates [SendingFrame]

  val source: Source[SendingFrame, Future[Done]] = StompClientSource(settings)

Last step is to materialize and run the source we created.

  val sink = Sink.head[SendingFrame]
  val (futConnected: Future[Done], futHead: Future[SendingFrame]) = source.toMat(sink)(Keep.both).run()

Running an example code

The code in this guide is part of runnable tests of this project. You are welcome to edit the code and run it in sbt.

Test code does not require an STOMP server running in the background, since it creates one per test using Vertx Stomp library.

Scala : sbt > test

Versions

Version
0.1.2