TheKidCof,

In order to transfer regular text files over the service bus, you should specify another Marshaler, which transforms the plain text file to an XML message and back again. You can write your own Marshaler, extending DefaultFileMarshaler, but ServiceMix also contains org.apache.servicemix.components.util.SimpleFlatFileMarshaler, which appears to be what you need. My guess is that you just have to create the bean (using Spring syntax?) and assign it to the marshaler attribute, but I have never used it myself, so I don't have any working code snippets to get you started...


Regards,

Gert


Thekidcof wrote:
Well, it creates the file in the senders folder however it's empty. This is
the error msg i get. The question is how how can i transfer regular text
files? , non xml files.
What I would like to do is this , have service mix polling via ftp a folder
for files on another computer and transfer the files to my local computer,
then once the file arrives have servicemixFTP scan the directory for the
files and once it picks up the files, send a message VIA JMS to a webservice
or EJB(3.0) stateless, then i will process the files. I'm using geronimo 2.0
m3(my own complied version, I fixed a few bugs in it already.) This is my
goal. The problem is I have never worked with serviceMIX and it's hard to
find books or documents on how things work in serviceMIX when it comes to
serviceMIX-FTP or File.

In advance, Thank you again for all your help.

TheKidCof


[Fatal Error] RadsCell.txt:1:1: Content is not allowed in prolog.
ERROR - FtpComponent                   - Error processing exchange InOnly[
  id: ID:D11711B1-2133-1184467218759-4:57
  status: Active
  role: provider
  service: {http://my.own/smx}sender
  endpoint: endpoint
  in: Unable to display: java.net.SocketException: socket closed
]
javax.jbi.messaging.MessagingException:
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
Content is not allowed in prolog.
        at
org.apache.servicemix.components.util.DefaultFileMarshaler.writeMessageContent(DefaultFileMarshaler.java:140)
        at
org.apache.servicemix.components.util.DefaultFileMarshaler.writeMessage(DefaultFileMarshaler.java:75)
        at
org.apache.servicemix.ftp.FtpSenderEndpoint.processInOnly(FtpSenderEndpoint.java:165)
        at
org.apache.servicemix.common.endpoints.ProviderEndpoint.process(ProviderEndpoint.java:100)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:489)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:441)
        at
org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:593)
        at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:174)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
        at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
        at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
        at java.lang.Thread.run(Thread.java:595)
Caused by: javax.xml.transform.TransformerException:
org.xml.sax.SAXParseException: Content is not allowed in prolog.
        at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
        at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toResult(SourceTransformer.java:85)
        at
org.apache.servicemix.components.util.DefaultFileMarshaler.writeMessageContent(DefaultFileMarshaler.java:138)
        ... 13 more
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
        ... 15 more
ERROR - FtpComponent                   - Failed to process file:
/RadsCell.txt. Reason: javax.jbi.messaging.MessagingException:
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
Content is not
 allowed in prolog.
javax.jbi.messaging.MessagingException:
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
Content is not allowed in prolog.
        at
org.apache.servicemix.components.util.DefaultFileMarshaler.writeMessageContent(DefaultFileMarshaler.java:140)
        at
org.apache.servicemix.components.util.DefaultFileMarshaler.writeMessage(DefaultFileMarshaler.java:75)
        at
org.apache.servicemix.ftp.FtpSenderEndpoint.processInOnly(FtpSenderEndpoint.java:165)
        at
org.apache.servicemix.common.endpoints.ProviderEndpoint.process(ProviderEndpoint.java:100)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:489)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:441)
        at
org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:593)
        at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:174)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
        at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
        at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
        at java.lang.Thread.run(Thread.java:595)
Caused by: javax.xml.transform.TransformerException:
org.xml.sax.SAXParseException: Content is not allowed in prolog.
        at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
        at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toResult(SourceTransformer.java:85)
        at
org.apache.servicemix.components.util.DefaultFileMarshaler.writeMessageContent(DefaultFileMarshaler.java:138)
        ... 13 more
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform
(TransformerIdentityImpl.java:484)




Gert Vanthienen wrote:
TheKidCof,


In the previous example, the file was copied from one FTP location (referred to by <ftp:poller/>) to another (the <ftp:sender/>)

If you want to store the files in a local directory, you'll have to create a second SU, using servicemix-file. Create the zip file (my-file-su.zip) which contains an xbean.xml file like this
<beans xmlns:file="http://servicemix.apache.org/file/1.0";
       xmlns:my="http://my.own/smx";>

    <file:sender service="my:file-sender" endpoint="endpoint"
        uri="..." />

</beans>

Add my-file-su.zip to your service assembly and update META-INF/jbi.xml to
reflect the additional SU, adding this <service-unit/> block:
<service-unit>
    <identification>
        <name>my-su</name>
        <description>My First :: File Service Unit</description>
    </identification>
    <target>
        <artifacts-zip>my-file-su.zip</artifacts-zip>
        <component-name>servicemix-file</component-name>
    </target>
</service-unit>

Now, you can change the targetService and targetEndpoint attribute of the
<ftp:poller/> element to connect it to your <file:sender/> to finish up
your configuration.

Is this the information you were looking for?

Regards,

Gert



Thekidcof wrote:
Hey Gert,

       Thank you so much for your help. It worked, however where does it
copy the file to? I want the FTP component to copy a text file to
directory
of my choosing. How do i get the xbean to configured to ftp the file to
the
folder of my choice?

If you could help me out that would be great.

TheKidCof

Gert Vanthienen wrote:
TheKidcof,


First, create a zip file (my-su.zip) which contains the xbean.xml file with your configuration, something like this:
<beans xmlns:ftp="http://servicemix.apache.org/ftp/1.0";
              xmlns:my="http://my.own/smx";>

    <ftp:poller service="my:poller" endpoint="endpoint"
        targetService="my:sender" targetEndpoint="endpoint"
        uri="..." />

    <ftp:sender service="my:sender" endpoint="endpoint"
        uri="..." />

</beans>

Next, create a zip file (my-sa.zip) which contains the previous ZIP file and META-INF/jbi.xml:
<jbi xmlns="http://java.sun.com/xml/ns/jbi"; version="1.0">
    <service-assembly>
        <identification>
            <name>my-sa</name>
            <description>My First :: SA</description>
        </identification>
        <service-unit>
            <identification>
                <name>my-su</name>
                <description>My First :: FTP Service Unit</description>
            </identification>
            <target>
                <artifacts-zip>my-su.zip</artifacts-zip>
                <component-name>servicemix-ftp</component-name>
            </target>
        </service-unit>
    </service-assembly>
</jbi>

Now, install the servicemix-ftp component (just copy the installer zip you find in /components to /deploy) and any required components. If everything is OK, just copy the my-sa.zip to the /deploy directory and you should be up and running.

Hope this helps,

Gert


Thekidcof wrote:
Can anyone help me out. I have installed the servicemix-FTP component
however, when I try to run the example
(http://incubator.apache.org/servicemix/servicemix-ftp.html) using
xbean.xml
it doesn't work. What are the steps to creating\configuring\deploying
an
Xbean.xml file for the service mix-FTP component? The steps on the
above
mentioned link aren't detailed enough for me.

I am new to service mix therefore anyhelp would be greatly appreciated.

TheKidcof



Reply via email to