Tuesday, December 3, 2019

ActiveMQ: Bridging Topics to Queues

Most recently, I had the need to create a bridge from Topics to Queues to create stateless services that can pick up messages in parallel. Essentially, I wanted to configure the following (in the message broker):

Topic to Queue Bridge
While there are many other ways to do this, I wanted to experiment with ActiveMQ support for this. The following is how I configured it locally (in my dev box):

Spring: Implicit Construction Injection

Over the years, Spring has made a number of enhancements to improve the developer UX. I realize some of these can be too trivial to notice. Today, I present one available since the 4.3 release (over 2 years ago).

Monday, December 2, 2019

Lessons Learned using Togglz

Feature Toggles (a.k.a. Feature Flags) are a common way to test new features in a production environment. I started to experiment with Togglz as a OSS library to implement what I needed. For the purpose of my description, I used Spring Boot as it makes apps development simpler. Here are my findings:

Sunday, December 1, 2019

Git: refusing to merge unrelated histories

Most recently, I found the following error during a git operation:
 
   $ git pull
   fatal: refusing to merge unrelated histories

which led me to a hunt. I found out that since version 2.9.0, git has removed the ability to merge branches with unrelated histories (thanks for the obvious message Git). This change (and many others) can be found here.

Saturday, November 30, 2019

Starting a Project: Data Generator

Sometimes, there is a need to generate data to test your code. While "testing in production" is a sweet spot to be, there are times when you need to "force" (stub) data that reflects certain business phenomena in production. This does not mean "chaos engineering" but rather a finite set that can be ingested into a suite of integration tests to increase confidence in code change.

Tuesday, March 26, 2019

Distributed Spring Integration

Recently, I was given an opportunity to code a use case that required the need to use EIP in a distributed environment. While trying to use the "Splitter" and "Aggregator" patterns, I had a chance to review the source code implementation of many of the components used to implement these using Spring Integration.

Monday, June 5, 2017

JSON on BASH: JQ

In one of my previous posts, I wrote about underscore-cli for looking at JSON output (e.g. to see the curl response from a REST web service). An alternative to this is jq, a command line processor for JSON in bash.

Some things about jq that make it powerful is that it can be used as a filter (that what jq really is). This means that you can select which parts of the JSON buffer be returned from the stream so that you can you do your own navigation.

For more information, check out https://stedolan.github.io/jq/tutorial/

Friday, April 28, 2017

Documenting Architecture Decisions - ADR

As I reviewed the 2017 Thoughtworks technology techniques trends, one cool recommendation was about to "try" the concept of Lightweight Architecture Decision Records. I must admit, I have been looking for something like this as I'm tired of having note pads everywhere, and I'm really trying to stay away from MS-Word documents and Powerpoints for developers. I have been looking for something lightweight, easy for developers to follow.

Saturday, April 22, 2017

Twelve Factor Apps: Spring Cloud Config


I have been using Spring for many years now and I really like the simplicity and non-invasive model of its features. As I have been implementing 12 Factor applications, I needed to start using a central way to configure the many microservices we are building. This is where Spring Cloud Config comes to the rescue.

Saturday, March 4, 2017

REST Endpoint returning 404 without Exceptions

At some point in your REST endpoint design, you will need to return a non 200 response. Now, most implementations show how to implement this using exceptions. While this may seem like a nice approach (from a programming language point of view), exceptions can add overhead to the running JVM. This translates to ineffective use of resources of the JVM for supporting non 200 responses.

Here is a gist where you don't use exceptions to return non 200 responses:


A few things to note from this snippet:
  1. This is a Spring Boot implementation (Boot makes things so much simple)
  2. The HttpServletResponse is injected by Boot (Spring MVC), no need of additional setup.
  3. Notice that the body return is null already, so the non 200 response makes more sense.
Please note that this is an implementation specific construct to support non 200 responses. Jersey and others also provide a non exceptional way to handle this scenario. Semantics of what the endpoint does (nouns non verbs, uniform contracts, interfaces, etc) are not part of the discussion. This is strictly an implementation description meant to support the abstraction defined by the given REST endpoint.

Friday, February 10, 2017

Presentation on Spring Boot

A few months ago, I was invited to speak on Spring Boot and Cloud Native. This was a good discussion. It was fun to build an app from scratch using Boot. For those interested, you can find the app in my github account:

https://github.com/albertoaflores/spring-boot-demo

Slides used for that preso can be found here:

http://www.slideshare.net/albertoaflores/spring-boot-intro

Hope some find this useful.

Thursday, April 2, 2015

Managing Service Brokers in CF

The existing CloudFoundry architecture includes a layer to support "Service Brokers".
CF Components
As such, CF includes a registry to manage "Service Broker" implementations. You can use this registry to configure the availability of services (including plans within a service) to different organizations. This is among the things that makes CloudFoundry a very powerful platform. I wrote a simple broker that should give you a quick overview of how to use it with CF. This is found here:

https://github.com/albertoaflores/dummy-cf-service-broker

Monday, March 30, 2015

Deploying Ozone on CloudFoundry

The Ozone Widget Framework (OWF) is a set of tools to enable "widgets" in the UI to communicate to each other. I must admit that the framework (or platform) was an early approach to projects such as "Rave" or "Wookie" (Apache), yet I've been asked if CloudFoundry supports it. While my experience using OWF has been somewhat painful, I noticed that an OWF deployment requires a server that is "optimized" for its deployment.  As such, OWF can work on CF using the "buildpack" feature. I suspect you can argue that OWF can be re-written as a web application component to work with the "standalone" java buildpack, however such work is beyond the scope of this post. This post describes what I had to do to create the "ozone-buildpack" to get this working.

Friday, March 27, 2015

Vagrant Script: BOSH CLI environment

I just published a Vagrant file (and configuration) for whoever wants to start picking up some BOSH CLI and/or CF CLI development. I'm experimenting with BOSH, so I figure I'll share my config. This is found here:

https://github.com/albertoaflores/vagrant-dev-base

I hope others find it useful.

Just do a vagrant up and you are good to go.

Thursday, March 26, 2015

Personal Notes: Tokens for the CloudFoundry API

In using CloudFoundry, I find myself using the CLI more often than not. This works for me very well because I enjoy using CLIs more often than not, however some things can also be done with scripting.

CloudFoundry introduces a REST API available to your installation. This is found here. One of the things you'll notice quickly is that one of the headers has to have an "authorization" token. This can be obtained by running the command:

cf oauth-token

The results can be added to the curl commands as described in the API docs. So that means that something like:

curl "https://$DOMAIN_URL/v2/apps" -X GET \
     -H "Authorization: $TOKEN"

where $DOMAIN_URL is your CloudFoundry API Endpoint, and $TOKEN is whatever is returned by the cf oauth-token command.

Of course, if you simply prefer to make straight calls to the API, you can use the cf curl command which adds these headers to your HTTP request for free (pending authentication to your given CF instance). So for the example above, you'll have something like this:

cf curl /v2/apps

I'm looking forward to experiment with other CF components shortly such as BOSH.

Tuesday, March 24, 2015

Spring Boot and CloudFoundry

In this post, I'll discuss my experience with Spring-Boot, how its features are making my "rapid prototyping" abilities shine (making me look good) and combined with a nice PaaS such as CloudFoundry, you can finally see how a true "agile" practice can focus on "innovation".

I added most of a sample code for this in a github repo. Feel free to use it and ping me if you need help or have questions:

https://github.com/albertoaflores/uspto-sample-app

Wednesday, September 3, 2014

Real PaaS: CloudFoundry

During the last few years in Software Development, I have found myself doing very repetitive tasks regarding deployment of applications. Among them, these are:
  • Provisioning of Hardware (or VM)
  • Install Application Runtime (Java, Rails, Node, etc)
  • Deploying of Binaries (War file, Processes, etc)
  • Load Balancer Configuration
  • Security Configuration (SSL, Documents, etc)
  • Ensure Service Connectivity to external systems (databases, enterprise logs, auditing, etc)
  • Update Firewall policies and documentation.
I have scripted most of these in many ways (particularly using Bash,  Puppet, Monit, etc). Most of these are not only done by me, but also prevent me from doing actual real work (developing solutions). If you find yourself in this situation, I'd like to introduce you to CloudFoundry, a PaaS project I have been following for some time. I'll plan on adding more entries on these concepts soon so that I can try to document my learning about this great platform.

Thursday, January 16, 2014

Handling JSON in bash using underscore

Now on days, software components expose some sort of API using a REST interface. In addition, the typical response comes in JSON format. While this very convenient for a browser to interpret, using JSON in a bash script is not as simple. I came across this project on github called underscore and I must admit I liked it. I highly recommend reading it's short README file. I figured I'd write some about my issues installing it.

Tuesday, July 3, 2012

Surefire/Failsafe maven plugin and SSL

I was puzzled today by an interesting feature introduced by the "surefire" and "failsafe" maven plugins (used for unit/integration test my components). These were introduced with their 2.1 release.  As I had components calling web services using 2-way SSL for authentication, I noticed that my test cases where failing when using maven via command line (mvn clean install). They worked on the IDE (Eclipse/STS) fine, but were not working on the command line. I saw the following error:
PKIX path building failed: ... unable to find valid certification path to requested target
 So it was clear that maven was not passing the SSL system properties from my .mavenrc file:


This is what I discovered as I read more the documentation.