Labels

algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)

Hello World File SU (service Mix)

Create a Maven Project
create a empty folder and create a pom.xml with the following content
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bytes.tutorial</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>bytes</name>
<url>http://servicemix.org</url>
<modules>
<module>bytes-sa</module>
</modules>
</project>

Create a Service Assembly

mvn archetype:generate -DarchetypeArtifactId=servicemix-service-assembly
-DarchetypeGroupId=org.apache.servicemix.tooling -DartifactId=bytes-sa

(Note: this will also add an entry into the above pom.xml dependency list)
you will get a prompt asking for
Define value for property 'groupId': : com.bytes.tutorial
[INFO] Using property: artifactId = bytes-sa
Define value for property 'version': 1.0-SNAPSHOT:
Define value for property 'package': com.bytes.tutorial:
Confirm properties configuration:
groupId: com.bytes.tutorial
artifactId: bytes-sa
version: 1.0-SNAPSHOT
package: com.bytes.tutorial
Y: y

Create a Service Unit(File SU)

Command to create a SU

mvn archetype:generate -DarchetypeGroupId=org.ap
ache.servicemix.tooling -DarchetypeArtifactId=servicemix-file-service-unit -Darc
hetypeVersion=2010.01 -DgroupId=com.bytes.tutorial -DartifactId=file-su


[INFO] Using property: groupId = com.bytes.tutorial
[INFO] Using property: artifactId = file-su
[INFO] Using property: version = 1.0
[INFO] Using property: package = com.bytes.tutorial
Confirm properties configuration:
groupId: com.bytes.tutorial
artifactId: file-su
version: 1.0
package: com.bytes.tutorial
Y: y

RUN mvn install

---------------------------------------------------------------
Reactor Summary:
---------------------------------------------------------------
bytes ............................................... SUCCESS
bytes SA ............................................ SUCCESS
Apache ServiceMix :: File Service Unit ................ SUCCESS

---------------------------------------------------------------
---------------------------------------------------------------
BUILD SUCCESSFUL

which means the project is configured successfully.

FILE-SU CONFIGURATION

we will configure the FILE-SU in such a way that the poller polls a director for valid XML files and gives them to file-sender ,

the file sender copies them into another folder

POLLER < =   D:\SOURCE
||
V
SENDER =>  D:\DESTINATION
open the XBEAN.XML under FILE-SU  you would find a poller tag like the one below
POLLER CONFIG
  <file:poller service="bytes:file_poller" endpoint="file-poller"
targetService="bytes:file_sender"
targetEndpoint="file-sender"
file="file:C:/SOURCE">





  1. Give the name of the poller service and its end point.
  2. The target service, end point to which the file polled is sent.
  3. File: the directory which has to be polled regularly for XML files.
SENDER CONFIG

<file:sender service="bytes:file_sender"
endpoint="file-sender"
directory="file:/D:/DESTINATION">






  1. name of the sender service should match the targetService of the poller 

  2. configure the directory where the files should be sent “directory”
do an mvn install and then go to the service assembly folder
and pick the jar file from the target and deploy in the hotdeploy 
folder of service mix and see the MAGIC.
download the sample here

No comments:

Post a Comment

Search 24 Bytes