Some of you might have a knowledge that one of the IT company has created a technical test. For recruitment process of course. I decided to take up this challenge. Below you can find a solution of it. I posted this only for educational purposes.
The projects is splited into two modules : currencyfair-gateway and currencyfair-consumer.
The first module currencyfair-gateway is responsible for exposing endpoint used for retriving from user request in JSON format. Request is validated due to it's fields. If request is not valid user will receive detailed information about which fields are incorrect. Otherwise request will be forwarded to message broker RabbitMQ.
The second module currencyfair-consumer fetches messages from message broker RabbitMQ to process it via Data Processor. Once it's done the processed data are broadcasted to frontend.
Application was developed using of course Java and Spring Framework. Those above two modules were connected via message broker RabbitMQ. Below you can see what is the overall architecture of this application. Other used libraries :
- Spring Beans – 4.0.1.RELEASE
- Spring Tx – 4.0.1.RELEASE
- Spring Context – 4.0.1.RELEASE
- Spring Context Support – 4.0.1.RELEASE
- Spring Aop – 4.0.1.RELEASE
- Spring Aspects - 4.0.1.RELEASE
- Spring Web – 4.0.1.RELEASE
- Spring Web MVC – 4.0.1.RELEASE
- Spring AMQP - 1.4.5.RELEASE
- Spring Erlang - 1.4.5.RELEASE
- Spring Rabbit - 1.4.5.RELEASE
- Spring WebSocket - 4.0.1.RELEASE
- Spring Messaging - 4.0.1.RELEASE
- Spring Integration - 4.1.0.RELEASE
- Spring Integration AMQP - 4.1.0.RELEASE
- Spring Integration Stream - 4.1.0.RELEASE
- Spring Test - 4.0.1.RELEASE
- Jackson Core - 2.5.0
- Jackson Databind - 2.5.0
- Jackson Annotations - 2.5.0
- Jackson Mapper ASL – 1.9.10
- Gson – 2.2.4
- Guava - 18.0
- Unirest - 1.4.5
- Javax Servlet API – 3.1.0
- JSTL – 1.2
- SLF4J - 1.7.8
- Commons Logging - 1.2
- JUnit - 4.10
- Mockito - 1.9.5
- Hamcrest - 1.3
- Highcharts - 4.1.5
- Twitter Bootstrap - 3.3.4
- SockJS - 0.3.4
![]() |
| Architecture |
Endpoint
Endpoint consumes JSON data on context /currencyfair-gateway/endpoint like below :{
"userId": "12345",
"currencyFrom": "EUR",
"currencyTo": "GBP",
"amountSell": 1000,
"amountBuy": 747.10,
"rate": 0.7471,
"timePlaced" : "24-JAN-15 10:27:44",
"originatingCountry" : "FR"
}
Message is validated under empty of above fields, timePlaced format (dd-MMM-yy hh:mm:ss), existing of currencyFrom and currencyTo in ISO 4217, existing of originatinCountry in ISO 3166-1 and by calculations of amountSell, amountBuy and rate.
Data processor
GraphBroker
Frontend
References : [1] https://github.com/GarciaPL/CurrencyFair
I recently uploaded my portfolio on GitHub Pages. If you are interested in projects which was developed just visit below website :
GarciaPL.github.io
Could not Autowire. No beans of 'SimpMessagingTemplate' type found
by GarciaPL on Saturday, 6 June 2015
My main IDE which is used at this time to develop for example Spring application is IntelliJ IDEA 13.1. My last project is built on Spring Framework 4. There is no so much problems with it, but there is one with Spring WebSocket. When you are going to autowire SimpMessagingTemplate object there is an error :
"Could not Autowire. No beans of 'SimpMessagingTemplate' type found"
The solution is very simple. Just add in your bean xml, in my case it's dispatcher-servlet.xml this line :
<context:component-scan base-package="org.springframework.web.socket.config"/>
As far as I know this problem is fixed in Intellij IDEA 14.0. Below you can read about ticket which is strictly related with this issue.
If this solution above did not work perhaps you need to move bean definition of your class which contains Autowired field of SimpMessagingTemplate to dispatcher-servlet.xml, I mean context which is pointed in your web.xml by org.springframework.web.servlet.DispatcherServlet.
Reference :
[1] Jetbrains IDEA-123964
My recent project was aimed to develop standalone application written in Swing with embedded database which was in form of JSON file. During building my Jar using Maven, I was faced with problem to replace this JSON file before final application will be produced. Before you will prepare such solution you should get familiar with Maven Build Lifecycle [1]. Below I listed those LifeCycle's :
- validate
- generate-sources
- process-sources
- generate-resources
- process-resources
- compile
- process-classes
- generate-test-sources
- process-test-sources
- generate-test-resources
- process-test-resources
- test-compile
- test
- prepare-package (maven 2.1+)
- package
- pre-integration-test
- integration-test
- post-integration-test
- verify
- install
- deploy
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>fetchJSON</id>
<phase>prepare-package</phase>
<inherited>false</inherited>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>pl.avantis.iom.rest.DrupalQueriesImpl</mainClass>
<cleanupDaemonThreads>true</cleanupDaemonThreads>
<daemonThreadJoinTimeout>30000</daemonThreadJoinTimeout>
</configuration>
</plugin>
Reference : [1] Maven Build Lifecycle [2] Codehaus - Exec Maven Plugin
Today I have released on GitHub two repositories which contain one of my recent project called TrafficCity. It was developed on hackathon called BIHAPI (Business Intelligence Hackathon API) organized by Orange Poland.
Briefly describing what's it's about in this app - on the mobile app you can place your markers (waypoints) on Google Maps which describes your daily route to work/school. After that you can send those waypoints to server to further processing.
In Backend you can see what's routes are defined by users. Additionally you can upload OSM file which is strongly related with OpenStreetMap and after that you can see on particular area what's is the chance to appear traffic jam.
An application consists of Backend app written in Spring and mobile app written in Android. Application was mainly deployed on JBoss AS 7.1. Backend part is also using interfaces provided by Orange - SIM GeoLocalization API, SMS API, USSD API and by Warsaw City - Transport POI Maps.
Unfortunately, I think that application which is in alpha phase, probably would remain so. There a few things to do/fix on the Backend and Mobile part, but not at this moment. I hope that more appropriate time will come.
Below I allowed myself to post some screenshots from backend and mobile part of this application.
![]() |
| Dashboard |
![]() |
| Markers |
![]() |
| OSM Upload |
![]() |
| OSM Projects |
![]() |
| HeatMap |
![]() |
| Home |
![]() |
| Settings |
![]() |
| Transport Type |
![]() |
| First marker |
![]() |
| Multiple markers |
![]() |
| Daily route |
![]() |
| Settings |
Reference :
[1] GitHub TrafficCity Backend
[2] GitHub TrafficCity Android
[3] BIHAPI
Swing in my opinion is quite great framework or library whatever you prefer to create Java application on desktop. But after using it some time, I noticed that one of the disadvantage of Swing is that when you make some heavy calculation, that almost always your GUI is going to freeze. Of course you can not leave this in that way, so you must create some workaround. To make it happen you can use for instance Timer from javax.swing package of course.
final Timer timer = new Timer(200, null);
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (isRandomizeRows()) {
ContestTableModel contest = getContestTableModel();
Vector data = contest.getData();
Collections.shuffle(data);
contest.setData(data);
getTablePlayers().setModel(contest);
getContestTableModel().fireTableDataChanged();
}
}
};
As you can see method isRandomizeRows() only blocks execution of this Timer. I do not know why method .stop() which is implemented in this Timer simply does not work. Nevertheless there is a line where AbstractTableModel from our JTable is acquired (getContestTableModel()). After that you get data in Vector collection. Shuffle it's contents using Collections.shuffle(data) method. After that set data, set model and let to know JTable that it's data has changed.













