scala

Using Akka Dispatchers In Scala

Reading Time: 4 minutes Akka dispatchers are extremely important in Akka framework. They are directly responsible for optimal performance, throughput and scalability. Akka supports dispatchers for both event-driven lightweight threads and thread-based Actors. For thread-based Actors each dispatcher is bound to a dedicated OS thread. Default dispatcher is a single event-based dispatcher for all Actors created. The dispatcher used is this one: Dispatchers.globalExecutorBasedEventDrivenDispatcher For many cases it becomes mandatory Continue Reading

Power of Parallel Processing in Akka

Reading Time: 4 minutes If you have been following the Inphina blog and our work with Scala related technologies, you would have noticed a spurt in our blog feeds. The reason being that we have recently come out of a very successful massively scalable framework created with Akka. Inphina holds an active stake in the product and the details of the framework would follow once the embargo is over. Continue Reading

Manage Akka Actors With Supervisors

Reading Time: 4 minutes We are building a concurrent and massively scalable system using Akka framework. Akka uses light-weight Actor paradigm of managing concurrency. Most of the times a bunch of Akka actors are required for a common functionality; therefore we do tend to manage them as a group. This is where Akka Supervisor comes into the picture. Akka Supervisors are responsible for starting, stopping and monitoring child Akka Continue Reading

AMQP and AKKA

Reading Time: 3 minutes AMQP is a message protocol that deals with publishers and consumers. It would look a lot like JMS but it is not. The main entities are Exchanges, Queues and Bindings. Look at the following diagram So a producer would send a message to the exchange and it is the job of the message broker (RabbitMQ in our case) to ensure that the messages are delivered Continue Reading

Building a Plugin Based Architecture in Scala

Reading Time: 3 minutes A plugin based architecture has many advantages. Some of the common ones include Extending an application’s functionality without compiling it again Adding functionality without requiring access to the original source code. Replacing or adding new functionality becomes easy Help in organizing large projects Help in extending the functionality of the system to unimagined areas. I know this one sounds extreme but believe me it is Continue Reading

Akka Actors on Mac beating the S#!t Out of my Dell

Reading Time: 2 minutes Let me explain the scenario. We have n (tens, hundreds or thousands) of Akka actors listening to a queue on RabbitMQ server. So the scenario looks something like this AMQP.newConsumer(connection, ConsumerParameters("*", actor, Some(queueName), Some(exchangeParameters))) As you would notice, each of the actors gets a message from the Q and invokes a plugin to do the processing and returns the results back to the result Q. Continue Reading

Creating Object Pool(s) in Scala

Reading Time: 3 minutes We are currently working on a very exciting web scale project. The framework is built using Scala and Akka actors and till date we are quite pleased with the performance. The architecture is plugin based where we can dynamically add plugins to our framework for processing incoming messages. Now, this is where it gets interesting and is the reason for this post. Some of the Continue Reading

Starting Akka Project With SBT 0.10

Reading Time: 4 minutes I was starting with Akka project with SBT but found that the latest SBT is quite different from before. I tried to create AKKA project with latest SBT but got stuck. Old SBT used to ask to create a new project in case it did not find any in the directory. With new SBT it is not the case. If you want to know how Continue Reading

Scala Nuggets: Finding All Classes in a Package

Reading Time: 2 minutes Recently, while doing a project for one of our clients in the US, we had the opportunity to build a plugin based framework for the product. While, the details of the plugin framework are reserved as a topic of another post, in this one we would see how easy it is to find all the classes in a package using a utility provided by Clapper. Continue Reading

Working With Scala Collections

Reading Time: 2 minutes We have a monthly iBAT (Inphina Beer and Technology Sessions). We look forward to this day and it was Scala day this time. I presented on Scala collections. Scala collection is elegant and concise. Scala Collections like java is object-oriented and we can work with generic types. It is optionally persistent i.e can be mutable and immutable. It provides higher order methods like foreach, map Continue Reading

Scala Nuggets: Understanding Traits

Reading Time: 4 minutes Inphina provides specialized Scala consulting, training and offshoring … Learn more about Scala@Inphina! If you are coming from a Java background, then traits are interfaces++.  In scala, trait is a complete mixin solution where we can provide implementation in the trait as well as have classes mix-in the trait either when we declare classes or even when we are creating an instance of the class. Continue Reading

Working With Scala Test

Reading Time: 5 minutes Scala Test is an open source Test framework for the java platform. With Scala test we can either test java or Scala code. It integrates with popular existing tools like JUnit, TestNG and it is designed to do different styles of testing like Behavior Driven Design for example. Let’s have a look at a simple JUnit4 Test in Scala Test package com.inphina.ibat.junit import org.scalatest.junit.AssertionsForJUnit import Continue Reading

Scala Nuggets: Look Ma! My First DSL

Reading Time: 2 minutes DSL (Domain Specific Language) is a programming language or specification language dedicated to a particular problem domain, problem representation or a particular solution technique. So with a few Scala Nuggets on our way we are ready to write a DSL? Not quite but in this post we would touch upon a critical feature in Scala which makes writing DSL’s easy. Let us look at the Continue Reading