Well,

I take the example of the mail SU.

In eclipse, create a Java project (New -> Java Project).
Name the project "mail-su".

Now in the mail-su project, create a file named pom.xml and containing:

<?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>org.apache.servicemix.samples</groupId>
        <artifactId>mail-su</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jbi-service-unit</packaging>

        <dependencies>
                <dependency>
                        <groupId>org.apache.servicemix</groupId>
                        <artifactId>servicemix-mail</artifactId>
                        <version>2009.01</version>
                </dependency>
        </dependencies>

        <build>
                <plugins>
                        <plugin>
                                <groupId>org.apache.servicemix.tooling</groupId>
                                <artifactId>jbi-maven-plugin</artifactId>
                                <version>4.1</version>
                                <extensions>true</extensions>
                        </plugin>
                </plugins>
        </build>

</project>

After, in the mail-su project, you create a directory src/main/resources and you put the xbean.xml in this directory.

Once done, you can make:
mvn clean install eclipse:eclipse

The install goal will create the SU zip (that can be embedded in the SA) and eclipse:eclipse goal will setup the project to be eclipse compliant.

Make a eclipse project refresh and it should be fine :)

Regards
JB

FuinhaAzul wrote:
Great answer... This helped me to understant the diference between using the
servicemix file and a SA package.


I´m using eclipse to develop the project, but i´m not familiar with maven,
just with ant. But i have instaled maven and give a few tries.

My problem is how to create the JBI projects in eclipse...

Maybe can you help me, which maven commands I need to run, to build this
project? (I want to create a right package structure, without using ant
again)


Thanks in advance!








Jean-Baptiste Onofré wrote:
Hi,

I recommand to avoid the usage of the lightweight container and prefer the pure JBI form.

In your case, you need to define two SUs:
1/ a mail poller SU
2/ a file sender (writer)

Concerning the mail poller, you can define the following xbean.xml:

<beans xmlns:my="http://www.example.org/myService";
        xmlns:mail="http://servicemix.apache.org/mail/1.0";>
<mail:poller service="my:MailService" endpoint="MailPoller"
        targetService="my:MailService"
        targetEndpoint="MailFileWriter"
        period="10000"
        connection="imap://[email protected]:143/INBOX?password=xxxx"
        deleteProcessedMessages="false"
        processOnlyUnseenMessages="true"/>
</beans>

Create a maven project with this xbean as resources.

On the file endpoint side, you can define the following xbean.xml:

<beans xmlns:my="http://www.example.org/myService";
        xmlns:file="http://servicemix.apache.org/file/1.0";>
<file:sender service="my:MailService" endpoint="MailFileWriter"
        directory="file:/tmp/mailFiles"/>
</beans>

After that you can assemble both SU (the mail poller and file sender) into a SA and create the SA zip file.

Once done, you can deploy the SA zip file by copying it into the hotdeploy directory (if you use SMX3).

Regards
JB

FuinhaAzul wrote:
Hi there.

I´m trying to create a servicemix application that takes a email and put
the
content on a file. But i´m not understand how.  I did the file-binding
sample, but I´m not suceded to adapt this sample to use email.
This is waht I did:

servicemix.xml:


<beans xmlns:sm="http://servicemix.apache.org/config/1.0";
xmlns:foo="http://servicemix.org/demo/"; xmlns:mail="http://servicemix.apache.org/mail/1.0";>

  <bean id="jndi"
class="org.apache.xbean.spring.jndi.SpringInitialContextFactory" factory-method="makeInitialContext" singleton="true" />

        <!-- the JBI container -->
        <sm:container id="jbi" useMBeanServer="true" createMBeanServer="true">

                <sm:activationSpecs>

                        <!-- Write files to the outbox directory -->
                        <sm:activationSpec componentName="fileSender"
                                service="foo:fileSender">
                                <sm:component>
                                        <bean 
class="org.apache.servicemix.components.file.FileWriter">
                                                <property name="directory" 
value="outbox" />

                                        </bean>
                                </sm:component>
                        </sm:activationSpec>

                        <sm:activationSpec componentName="emailPoller"
                                service="emailPoller" 
destinationService="foo:fileSender">
                                <sm:component>
                                        <bean 
class="org.apache.servicemix.components.email.MimeMailPoller">
                                                <property name="hostName" 
value="xxxxx" />
                                                <property name="password" 
value="xxxx" />
                                                <property name="userName" 
value="xxx" />
                                                <property name="debug" 
value="true" />
                                                
                                        </bean>
                                </sm:component>
                        </sm:activationSpec>
                        
                </sm:activationSpecs>
        </sm:container>

</beans>



Reply via email to