Skip to content

Instantly share code, notes, and snippets.

@davideicardi
davideicardi / ConditionalFlow.scala
Created June 29, 2018 14:09
Conditional Akka Stream Flow
import akka._
import akka.stream._
import akka.stream.scaladsl._
import akka.actor._
// WARNING: Ordering is not guaranteed.
// The problem with this Graph is that when splitting the flow
// we obtain 2 concurrent flows.
// The result of conditionalFlow can returns after another messages is processed in the brodcast.
// ie. If you have 10 messages from 0 to 9. Let's say that we run a conditional flow only for element 0.
@davideicardi
davideicardi / PassThroughFlow.scala
Last active June 6, 2022 08:32
Akka stream generic pass through flow. For latest implementation see https://developer.lightbend.com/docs/alpakka/current/patterns.html#passthrough
/*
https://scalafiddle.io/sf/sniohcZ/3
(old version: https://scalafiddle.io/sf/sniohcZ/1)
Use PassThroughFlow when you have a message that should be used in a
flow that trasform it but you want to maintain the original message for
another following flow.
For example if you consume messages from Kafka (CommittableMessage).
You process the message (transform, save it inside a database, ...) and then you need again the original message
to commit the offset.
@davideicardi
davideicardi / README.md
Last active June 26, 2018 13:54
Alpakka HBase connector, write Akka messages to HBase
@davideicardi
davideicardi / README.md
Last active June 22, 2020 04:39
Alpakka Kafka connector (akka-stream-kafka) example. Produce and consumer kafka messages using Akka Stream.

Alpakka Kafka connector (akka-stream-kafka) example

Simple solution to use Alpakka Kafka connector to produce and consume kafka messages.

I assume that you have 2 scala apps, a producer and a consumer.

Producer

Add the following dependencies:

@davideicardi
davideicardi / sbt-multiprojects-guide.md
Last active October 1, 2019 09:31
Scala/sbt minimal multi projects setup

Scala/sbt minimal multi projects setup

Assume that you have the following directory structure:

  • your-app
    • project1
      • src
        • main
          • scala
            • App.scala
@davideicardi
davideicardi / schema.xml
Last active June 11, 2018 17:09
Basic SolR 4 (Cloudera 5) configurations
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@davideicardi
davideicardi / cloudera-docker.md
Last active April 4, 2024 19:00
Running Cloudera with Docker for development/test
@davideicardi
davideicardi / BsonToJson.cs
Last active April 28, 2024 14:49
BsonDocument to Json string
// This method convert a json to a valid string json
// It should handle all mongodb data types correctly (Date, ObjectId, ...) thanks to the
// Newtonsoft.Json.Bson.BsonReader serializer
public string ToJson(BsonDocument bson)
{
using (var stream = new MemoryStream())
{
using (var writer = new BsonBinaryWriter(stream))
{
@davideicardi
davideicardi / guide.md
Last active July 30, 2018 13:49
Steps to convert .csproj to new VS 2017 format (.NET 4.5 to .NET Core)

Convert a .NET 4.x project to .NET Core

Steps to convert .csproj to new VS 2017 format (.NET 4.5 to .NET Core)

  • delete any files inside the project folder but not included in the project
  • unload project from visual studio
  • edit .csproj
  • a .csproj template with nuget packages, nuget info, code analysis, style cop:
@davideicardi
davideicardi / README.md
Last active March 7, 2018 16:37
Development mongodb cluster tutorial