camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Artix Data Services
Date Thu, 01 Oct 2009 13:25:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/Artix+Data+Services">Artix
Data Services</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="ArtixDataServices-ArtixDataServices"></a>Artix Data
Services</h2>
<p><b>Deprecated, will be removed in Apache Camel 2.1</b></p>

<p>The Artix DS <a href="/confluence/display/CAMEL/Data+Format" title="Data Format">Data
Format</a> supports the <a href="http://www.iona.com/artix/ds" rel="nofollow">Artix
Data Services (ADS)</a> product which provides a framework for reading and writing a
huge number of vertical message payloads like SWIFT, SEPA, FpML, TWIST, ISO 20022, CREST and
FIX. In addition ADS provides tooling and a framework for reading and writing any legacy binary
or text file using any kind of encoding like fixed width, delimited, XML, CSV and so forth.
</p>

<p>ADS also provides a transformation framework making it very easy to implement the
<a href="/confluence/display/CAMEL/Message+Translator" title="Message Translator">Message
Translator</a> pattern using the ADS tooling to design the transformation.</p>

<h3><a name="ArtixDataServices-Unmarhalling"></a>Unmarhalling</h3>

<p>The first step to using ADS is usually to unmarshal some message from one of the
Camel <a href="/confluence/display/CAMEL/Components" title="Components">Components</a>
like <a href="/confluence/display/CAMEL/File" title="File">File</a>, <a href="/confluence/display/CAMEL/HTTP"
title="HTTP">HTTP</a> or <a href="/confluence/display/CAMEL/JMS" title="JMS">JMS</a>
etc.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:InputQueue"</span>).
  unmarshal().artixDS(DocumentElement.class).
  to(<span class="code-quote">"mqseries:OutputQueue"</span>);
</pre>
</div></div>

<p>The above unmarshals using the Artix DS <a href="/confluence/display/CAMEL/Data+Format"
title="Data Format">Data Format</a> for the element <b>DocumentElement</b>
which is generated by the Artix DS tooling; DocumentElement is the root element of the message
structure.</p>

<p>The above will use the default formatting for the data type. However with Artix DS
you can switch from the default format to other formats easily. So you could add a specific
format if you wish...</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:InputQueue"</span>).
  unmarshal().artixDS(DocumentElement.class, ArtixDSContentType.Xml).
  to(<span class="code-quote">"mqseries:OutputQueue"</span>);
</pre>
</div></div>

<p>If you use static imports this can be even more readable...</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  unmarshal().artixDS(DocumentElement.class, Xml).
</pre>
</div></div>

<h4><a name="ArtixDataServices-UnmarshallingSWIFTmessages"></a>Unmarshalling
SWIFT messages</h4>

<p>If you are working with <a href="http://en.wikipedia.org/wiki/Society_for_Worldwide_Interbank_Financial_Telecommunication"
rel="nofollow">SWIFT</a> messages then as of camel-artixds version 1.3.6.0 or later
there is a handy SwiftFormat helper class which avoids you having to know which Element class
you want to use.</p>

<p>So you can unmarshal SWIFT messages using this code</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:InputQueue"</span>).
  unmarshal(<span class="code-keyword">new</span> SwiftFormat()).
  to(<span class="code-quote">"mqseries:OutputQueue"</span>);
</pre>
</div></div>

<h3><a name="ArtixDataServices-Marshalling"></a>Marshalling</h3>

<p>Marshalling is the reverse of unmarshalling suprise suprise <img class="emoticon"
src="/confluence/images/icons/emoticons/smile.gif" height="20" width="20" align="absmiddle"
alt="" border="0"/>.</p>

<p>Here's an example which unmarshals using one format (XML) and then marshals using
a different format (in this case tagged value pairs).</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:XmlInput"</span>).
	unmarshal().artixDS(DocumentElement.class, ArtixDSContentType.Xml).
	marshal().artixDS(ArtixDSContentType.TagValuePair).
  	to(<span class="code-quote">"mqseries:TagOutput"</span>);
</pre>
</div></div>

<h3><a name="ArtixDataServices-Typeconversions"></a>Type conversions </h3>

<p>An alternative to explicit unmarshalling in the DSL you can just use the common <b>convertBodyTo(Class)</b>
method in the DSL to convert using the default content type to a particular ComplexDataObject
from Artix DS. This mechanism uses the inbuilt Camel <a href="/confluence/display/CAMEL/Type+Converter"
title="Type Converter">Type Converter</a> mechanism ot automatically marshal and
unmarshal using the default content type for a model.</p>

<p>For example the following...</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:InputQueue"</span>).
  convertBodyTo(DocumentElement.class).
  to(<span class="code-quote">"mqseries:OutputQueue"</span>);
</pre>
</div></div>

<p>Is equivalent to this</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:InputQueue"</span>).
  unmarshal().artixDS(DocumentElement.class).
  to(<span class="code-quote">"mqseries:OutputQueue"</span>);
</pre>
</div></div>


<h3><a name="ArtixDataServices-UsingTransformations"></a>Using Transformations</h3>

<p>To use the <a href="/confluence/display/CAMEL/Message+Translator" title="Message
Translator">Message Translator</a> pattern with ADS its a simple matter of using
the ADS tooling to create your transformation, then just using the generated transformation
class in the <a href="/confluence/display/CAMEL/Bean+Integration" title="Bean Integration">Bean
Integration</a> in Camel.</p>

<p>For example image you define a transformation in the ADS IDE to translate SWIFT to
FIX format. You will then have a generated SwiftToFix Java class. You can then use the transformation
in your Camel <a href="/confluence/display/CAMEL/DSL" title="DSL">DSL</a> via
Java or the <a href="/confluence/display/CAMEL/Xml+Configuration" title="Xml Configuration">Xml
Configuration</a> as follows</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:SwiftQueue"</span>).
  bean(SwiftToFix.class).
  to(<span class="code-quote">"mqseries:FixQueue"</span>);
</pre>
</div></div>


<h3><a name="ArtixDataServices-ConfiguringviaSpringXML"></a>Configuring
via Spring XML</h3>

<p>The following example shows how to use Artix DS using <a href="/confluence/display/CAMEL/Spring"
title="Spring">Spring</a> XML; in this case it unmarshals the content of a JMS queue
as XML using the Artix DS data model; then marshals it using a tag/value pair.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
  <span class="code-tag">&lt;camelContext id=<span class="code-quote">"camel"</span>
xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
    <span class="code-tag">&lt;route&gt;</span>
      <span class="code-tag">&lt;from uri=<span class="code-quote">"activemq:MyInputQueue"</span>/&gt;</span>
      <span class="code-tag">&lt;unmarshal&gt;</span>
        <span class="code-tag">&lt;artixDS contentType=<span class="code-quote">"Xml"</span>
elementTypeName=<span class="code-quote">"iso.std.iso.x20022.tech.xsd.pacs.x008.x001.x01.DocumentElement"</span>/&gt;</span>
      <span class="code-tag">&lt;/unmarshal&gt;</span>
      <span class="code-tag">&lt;marshal&gt;</span>
        <span class="code-tag">&lt;artixDS contentType=<span class="code-quote">"TagValuePair"</span>/&gt;</span>
      <span class="code-tag">&lt;/marshal&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"mqseries:MyOutputQueue"</span>/&gt;</span>
    <span class="code-tag">&lt;/route&gt;</span>
  <span class="code-tag">&lt;/camelContext&gt;</span>
</pre>
</div></div>

<h3><a name="ArtixDataServices-ContentTypesandautodiscovery"></a>Content
Types and auto discovery</h3>

<p>You may have spotted in the above that we use the <a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/model/dataformat/ArtixDSContentType.html"
rel="nofollow">ArtixDSContentType</a> which is an <em>enum</em> in Java
and the <a href="/confluence/display/CAMEL/Xml+Configuration" title="Xml Configuration">Xml
Configuration</a> to describe the kind of XML format to use such as binary, XML, Text
etc.</p>

<p>If no content type is specified we always use the default content type of the Artix
DS model in question. This is equivalent to the <b>Default</b> content type.</p>

<p>If you wish to be flexible in what you accept or emit, we also support the <b>Auto</b>
content type which will look for the <b>Content-Type</b> header on the input message
and use that to try determine which of the content types to use; if none can be found then
<b>Default</b> is used.</p>

<p>e.g. you could support content posted with a MIME type of <b>application/xml</b>
to indicate XML or <b>application/x-java-serialized-object</b> for serialization
or <b>text/plain</b> for text etc.</p>

<h3><a name="ArtixDataServices-Usingcamelartixds"></a>Using camel-artixds</h3>

<p>To use this module you need to use the <a href="http://fusesource.com/products/enterprise-camel"
rel="nofollow">FUSE Mediation Router</a> distribution. Or you could just add the
following to your pom.xml, substituting the version number for the latest &amp; greatest
release.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
  &lt;artifactId&gt;camel-artixds&lt;/artifactId&gt;
  &lt;version&gt;1.5.3.0-fuse&lt;/version&gt;
&lt;/dependency&gt;
</pre>
</div></div>

<p>And ensure you are pointing at the maven repo</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
   &lt;repository&gt;
     &lt;id&gt;open.iona.m2&lt;/id&gt;
     &lt;name&gt;FUSESource Open Source Community Release Repository&lt;/name&gt;
     &lt;url&gt;http:<span class="code-comment">//repo.fusesource.com/maven2/&lt;/url&gt;
</span>     &lt;snapshots&gt;
       &lt;enabled&gt;<span class="code-keyword">false</span>&lt;/enabled&gt;
     &lt;/snapshots&gt;
     &lt;releases&gt;
       &lt;enabled&gt;<span class="code-keyword">true</span>&lt;/enabled&gt;
     &lt;/releases&gt;
   &lt;/repository&gt;
</pre>
</div></div>

     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Artix+Data+Services">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=68410&revisedVersion=13&originalVersion=12">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Artix+Data+Services?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message