Showing posts with label Camel. Show all posts
Showing posts with label Camel. Show all posts

Friday, April 13, 2012

3 reasons to use FuseSource Documentation

As an Apache Committer but also FuseSource Consultant and Solution Architect, the documentation and its quality is a critical factor in my day by day work. Until now, even using google search engine, that was difficult to find in one place all the information required and a wasting time.
This situation has changed and I will give you three reasons to use/adopt FuseSource documentation for your Apache Camel, Apache ServiceMix and Apache Karaf projects.


Reason 1 :  Fuse maintains history of Apache releases
Apache websites uses Atlassian Confluence to maintain content publishes for each Apache project. This tool does not allow to create a history of the different releases of Camel by example (2.6, 2.7, 2.8). This is not the case with FuseSource documentation which allow you to browse a specific version like the current. And with the help of google, you can make specific search like that
    site:fusesource.com/docs/router/2.8/ "followed by the keywords"
or 
    site:fusesource.com/docs/router "followed by the keywords"

Reason 2 : Javadoc and Schema are well documented
Javadoc like XML Schema are also 2 interesting examples as there is no XML Schema javadoc on Apache websites for by example Spring DSL language. This is completely different on FuseSource web site as you can read the documentation and discover what are the tags or attributes to be used for specific Apache Camel DSL words. Here is an example containing the options proposed for Apache Camel Dataformat.
     http://fusesource.com/docs/router/2.8/xmlref/http.camel.apache.org.2033734988/element/dataformats.html





Reason 3 : New chapters have been added
FuseSource documentation contains missing pieces of information or cover in depth points which are described poorly on Apache websites or in an disparate way. So take the time to read the following chapters when you need more info about Transactions, Security, ...

  • Camel and Transactions : http://fusesource.com/docs/router/2.8/transactions/front.html
  • Camel and WebServices : http://fusesource.com/docs/router/2.8/camel_cxf/front.html
  • Fuse ESB - Security guide : http://fusesource.com/docs/esb/4.4.1/esb_security/front.html
  • Transactions with Fuse ESB : http://fusesource.com/docs/esb/4.4.1/camel_tx/front.html
  • ActiveMQ - Security : http://fusesource.com/docs/esb/4.4.1/amq_security/front.html
  • ActiveMQ - Tuning Guide : http://fusesource.com/docs/esb/4.4.1/amq_tuning/front.html
____________________________






Friday, June 18, 2010

Parse / Format fixed length message with camel-bindy

Camel-bindy which is a data formatting tool to parse / format non XML message will be enriched in the next camel release 2.4. This new version will allow to work with Fixed Length message.

A Fixed Length message as its name mention it contains data positioned at a fixed position which is by far different from Comma Separate Value format where we use a separator.

So, you will be able able to model your message like that :


@FixedLengthRecord(length=60, paddingChar=' ')
public static class Order {

@DataField(pos = 1, length=2)
private int orderNr;

@DataField(pos = 3, length=2)
private String clientNr;

@DataField(pos = 5, length=9)
private String firstName;

@DataField(pos = 14, length=5, align="L")
private String lastName;

@DataField(pos = 19, length=4)
private String instrumentCode;

@DataField(pos = 23, length=10)
private String instrumentNumber;

@DataField(pos = 33, length=3)
private String orderType;

@DataField(pos = 36, length=5)
private String instrumentType;

@DataField(pos = 41, precision = 2, length=7)
private BigDecimal amount;

@DataField(pos = 48, length=3)
private String currency;

@DataField(pos = 51, length=10, pattern = "dd-MM-yyyy")
private Date orderDate;



to parse/format the following text :

"10A9 PaulineM ISINXD12345678BUYShare2500.45USD01-08-2009"

The tool allows to add 'padding' characters and to align "LEFT" or " RIGHT" the string in the field.

More info are available on the wiki web page of camel-bindy : http://camel.apache.org/bindy.html

Tuesday, March 17, 2009

Can Apache Camel be independent of the queuing engine ?

Designing and deploying an Apache Camel project in an environment where you have (as an administrator) the control is something very simple to do. Most of the time, the code that you will receive from the developers will be ready to be deployed on the server (ServiceMix, J2EE, ...).

But this is not the case, when you work in big companies where the infrastructure is separated from the teams in charge to design/build/deploy and release the application. As a developer you don't have access to the acceptance or production environment. This means that you must provide different configuration files to the builder team and/or release management in order to deploy your application in development, acceptance and production environment.

Obviously, the name of the servers are not the same and the infrastructure is in charge to manage the queues servers. In this environment, infra will never accept that the queues definition or creation of the queuing engine are under the responsibility of the developer(s). Thus, it will not be possible in your spring DSL file (or Camel Java DSL classes) to declare your queuing engine like this :

<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
<property name="brokerURL" value="vm://localhost:61616" / >
</bean >

remark: vm://localhost:61616 must be changed to serverName.intranet.domainName:port
depending on queuing engine deployed in the different environment.

To make Camel independent of its queuing engine :
  • ActiveMq,
  • WebSphereMQ,
  • SonicMq,
  • TIBCO,
  • ...
and parameters like :
  • Size of the queue,
  • Size of the messages accepted on the queue,
  • Persistence of the messages
  • ...
you must made different modifications. Let's assume that you plan to use ActiveMq as your queuing engine. Here is the list of the modifications to do :

1) Add the required bundles to your ServiceMix 4 osgi server to allow it to work with ActiveMq. Normally, the features transaction and activemq are activated by default in the file etc/org.apache.servicemix.features.cfg. So, you don't have to do anything else except if you use ServiceMix Kernel. In this case, you have to add the bundles manually or add a link (in the config file) to the features.xml file where the bundles have been declared

2) Create a spring xml file where the parameters of the queuing engine are defined. Luckily, such a file already exists and is available from Apache ServiceMix 4 project. So, copy the file into the deploy folder of ServiceMix 4 or Servicemix 4 Kernel

3) Create a osgi-queueservice.xml file containing the following lines and copy it in the deploy folder of ServiceMix

<?xml version="1.0" encoding="UTF-8"? >
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">

<bean id="active-mq" class="org.apache.activemq.camel.component.ActiveMQComponent" />

<osgi:service id="osgiqueuingservice" ref="active-mq" interface="org.apache.camel.Component"/>

</beans>

When the spring file will be at the server startup loaded by Spring (though its Application context), it will create the bean "active-mq" and instantiate the class : org.apache.activemq.camel.component.ActiveMQComponent.

Remarks :
- No parameters are provided to the ActiveMqComponent like brokerUrl, ...
- If you need to work with another JMS queuing engine, you can replace the class ActiveMQComponent by : org.apache.camel.component.jms.JmsComponent

Next it will create an OSGI service called "osgiqueuingservice" and expose it through the interfaces : org.apache.camel.Component

Remark : As JmsComponent, ActiveMqComponent implements this interface, the OSGI service is generic. So you could parameterized it using a property file (cfg file in the ServiceMix world)

4) The last step is very simple. In your camel config file, you add a reference to your osgi service in order to retrieve the queuing engine like this :

<osgi:reference id="queuingservice" interface="org.apache.camel.Component" />

Please remark that you import the Component interface. So, Camel becomes independent of the queuing engine used (WebSphere, TIBCO, ActiveMQ, ...)

and in your Camel route :

<camel:from uri="queuingservice:queue:in" />

Tuesday, December 9, 2008

Tutorial introducing How to create, design a simple SOA solution using Camel and OSGI

After a few weeks of investigation about OSGI, I have decided to start to write a tutorial showing How we can design/create a Service Oriented Architecture using Camel in combination with OSGI standard. The first part of this tutorial has been published and next part will come soon.

Through this tutorial, the user will see how such a solution can be designed and deployed in two really interesting products : ServiceMix Kernel server (based on Apache Felix) and Spring Dynamic Server (based on Eclipse Equinox).

Link : http://cwiki.apache.org/confluence/display/CAMEL/tutorial-osgi-camel-part1