Montag, 19. September 2016

HowTo: Change Camel route configuration during runtime

Introduction

In the following we are going to set up a dynamic configurable Camel route whose configuration can be changed during runtime without restarting the route. You may think that this sounds pretty easy but it turned out that it is not. So let me introduce you to the problem. 

Usually property placeholder are used to read properties from a configuration file. These properties can be used smoothly within route configuration but when the property is changed the update mechanism has no effect on the running route. The route has to be restarted to tighten the change. An automatic route restart can be achieved by configuring the appropriate update strategy within the property placeholder configuration. An example of this approach can be found in the Apache Camel documentation. I will quote the relevant snippet in the following.
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"  
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
       xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"  
       xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">  
   <!-- OSGI blueprint property placeholder -->  
   <cm:property-placeholder id="myblueprint.placeholder" persistent-id="camel.blueprint">  
     <!-- list some properties as needed -->  
     <cm:default-properties>  
       <cm:property name="result" value="mock:result"/>  
     </cm:default-properties>  
   </cm:property-placeholder>  
   <camelContext xmlns="http://camel.apache.org/schema/blueprint">  
     <!-- in the route we can use {{ }} placeholders which will lookup in blueprint  
        as Camel will auto detect the OSGi blueprint property placeholder and use it -->  
     <route>  
       <from uri="direct:start"/>  
       <to uri="mock:foo"/>  
       <to uri="{{result}}"/>  
     </route>  
   </camelContext>  
 </blueprint>  
The problem is that a route restart on a property change is often not acceptable as unintentional updates are triggered. So if you are okay with the restart, use the snippet from the Camel documentation if you want to get around restarting the route keep reading.

Freitag, 22. Juli 2016

HowTo: Make use of Spark Streaming

Introduction

I was searching for a (comparatively) simple use case of Apache Spark and finally found an interesting scenario. The plan is to analyze Tweets related to the US elections 2016 in real time to provide live feedback during the TV debates. 
For this purpose we are going to set up an Elasticsearch server and feed it with tweets using Apache Spark. In the process we will perform sentiment and location analyzation. Finally we will build some dashboards in Kibana to visualize the data. As these are quite many topics we are not going to deep into each but get a working sample at the end. The result will look like the following.
As always the whole project can be found on GitHub.

Freitag, 24. Juni 2016

Calling SOAP services via Camel

The samples querying a SOAP service via Camel I found are lagging important information. I was not able to handle the response rightly. Luckily google pointed me to the solution given by Claus Ibsen on Stackoverflow. As I have a complete working sample now, I am willing to share it with the world ;-).

The whole project can be found on GitHub.

Donnerstag, 19. Mai 2016

Querying Database via Camel

I recently stumpled a bit to query a database using Camel's JDBC component. The provided sample code on how to read the results was not working for me what is a bit strange because it is part of their tests.

Anyway if you have similar issues please find a working sample attached.

The whole project can be found on GitHub.

Mittwoch, 18. Mai 2016

Calling REST services via Camel

I recently tryed to call a REST service with Camel's CXFRS component and could not find an easy solution. So I tryed Camel's HTTP component and found out that it is working pretty straight forward.

Please find a working sample attached.

The whole project can be found on GitHub.

Dienstag, 4. November 2014

HowTo: Access Strava API from Java

Introduction

In the following we are going to access Strava's REST API from Java. As the Strava REST API requires OAuth we use Apache Oltu as Open Source OAuth framework.

Although the API is very rich on resources the focus of this tutorial is just the basic access, not the generation of any fancy reports (maybe we will do this later ;-)). 

If you don't know Strava grab your bike or running shoes and give it a shot.

Prerequisites

  • Strava Account

Donnerstag, 25. September 2014

HowTo: Host P2 repositories built by Tycho on Nexus

Introduction

In the following we are going to set up a Sonatype Nexus server which will provide p2 repositories. Besides proxying an existing p2 repository the Nexus server will host its own. For this purpose we will create a p2 repository from simple Maven dependencies using Tycho. As dependencies we take the libs from earlier Logging HowTo to cover a real use case. In the end a simple mvn deploy will get everything done.

Prerequesites