alpakka-connectors

Alpakka connectors to integrate external systems with Akka Streams

License

License

Categories

Categories

Akka Container Microservices Reactive libraries
GroupId

GroupId

no.sysco.middleware.alpakka
ArtifactId

ArtifactId

alpakka-connectors
Last Version

Last Version

0.1.10
Release Date

Release Date

Type

Type

pom
Description

Description

alpakka-connectors
Alpakka connectors to integrate external systems with Akka Streams
Project URL

Project URL

http://github.com/sysco-middleware/alpakka-connectors
Source Code Management

Source Code Management

http://github.com/sysco-middleware/alpakka-connectors/tree/master

Download alpakka-connectors

How to add to project

<!-- https://jarcasting.com/artifacts/no.sysco.middleware.alpakka/alpakka-connectors/ -->
<dependency>
    <groupId>no.sysco.middleware.alpakka</groupId>
    <artifactId>alpakka-connectors</artifactId>
    <version>0.1.10</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/no.sysco.middleware.alpakka/alpakka-connectors/
implementation 'no.sysco.middleware.alpakka:alpakka-connectors:0.1.10'
// https://jarcasting.com/artifacts/no.sysco.middleware.alpakka/alpakka-connectors/
implementation ("no.sysco.middleware.alpakka:alpakka-connectors:0.1.10")
'no.sysco.middleware.alpakka:alpakka-connectors:pom:0.1.10'
<dependency org="no.sysco.middleware.alpakka" name="alpakka-connectors" rev="0.1.10">
  <artifact name="alpakka-connectors" type="pom" />
</dependency>
@Grapes(
@Grab(group='no.sysco.middleware.alpakka', module='alpakka-connectors', version='0.1.10')
)
libraryDependencies += "no.sysco.middleware.alpakka" % "alpakka-connectors" % "0.1.10"
[no.sysco.middleware.alpakka/alpakka-connectors "0.1.10"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.6

Project Modules

  • alpakka-files
  • alpakka-zeromq
  • alpakka-brave

Alpakka Connectors

Build Status

Maven metadata URI

File Connectors

Listening to changes in a directory

The RecursiveDirectoryChangesSource tries to improve the existing DirectoryChangesSource from alpakka with recursive folder monitoring. It will emit elements every time there is a change to a watched directory in the local file system or any of the subdirectories (new or existing). The enumeration consists of the path that was changed and an enumeration describing what kind of change it was.

import no.sysco.middleware.alpakka.files.javadsl.RecursiveDirectoryChangesSource;

public class App {
    public static void main(String[] args){
        final ActorSystem system = ActorSyste.create();
        final ActorMaterializer mat = ActorMaterializer.create(system);
        
        final FileSystem fs = FileSystems.getDefault();
        final Duration pollingInterval = Duration.of(1, ChronoUnit.SECONDS);
        final int maxBufferSize = 1000;
        final Source<Pair<Path, DirectoryChange>, NotUsed> changes =
            RecursiveDirectoryChangesSource.create(fs.getPath(path), pollingInterval, maxBufferSize);


        changes.runForeach((Pair<Path, DirectoryChange> pair) -> {
            final Path changedPath = pair.first();
            final DirectoryChange change = pair.second();
            System.out.println("Path: " + changedPath + ", Change: " + change);
        }, mat);
    }
}

ZeroMQ Connectors

ZeroMQ Connector uses JeroMQ library to expose Source, Flow and Sinks based on ZeroMQ Socket types (e.g. PUB/SUB, PULL/PUSH).

import no.sysco.middleware.alpakka.zeromq.javadsl.Zmq;

public class App {
    public static void main(String[] args) {
        final ActorSystem system = ActorSystem.create();
        final ActorMaterializer mat = ActorMaterializer.create(system);
        
        Source.repeat("hello")
              .map(ZMsg::createNewMsg)
              .to(Zmq.publishServerSink("tcp://*:5555"))
              .run(mat);
        
        Zmq.subscribeClientSource("tcp://localhost:5555")
           .map(zmsg -> {
               System.out.println(zmsg.popString());
               return zmsg;
           })
           .runWith(Sink.ignore(), mat);
    }
}

Zipkin-Brave Connectors

Brave connectors create Spans flows to integrate tracing into your Akka Streams applications.

public class App {
  public static void main(String[] args){
    final ActorSystem system = ActorSystem.create();
        final ActorMaterializer mat = ActorMaterializer.create(system);
        
        final Tracing tracing = ...;
        
        Source.repeat("hello")
          .via(Brave.startSpanFlow(tracing, "akka-stream-trace"))
          .via(Brave.childSpanFlow(tracing, "akka-stream-span-map", Flow.<String>create().map(s -> s)))
          .via(Brave.finishSpanFlow(tracing))
          .to(Sink.ignore())
          .run(materializer);
  }
}
no.sysco.middleware.alpakka

SYSCO Middleware

Middleware Department from SYSCO AS

Versions

Version
0.1.10
0.1.6
0.1.3
0.1.1