Send Mediator with VFS error WSO2 ESB - wso2

I create a proxy and sequence to read file from source folder then write it to target folder with send mediator with VFS. My Proxy look like this :
<proxy name="XXX" transports="vfs" startOnLoad="true" trace="disable">
<description/>
<target>
<inSequence>
<property name="filename"
expression="fn:concat(get-property('transport', 'FILE_NAME'), '')"/>
<sequence key="write"/>
<log level="custom">
<property name="finish" value="finish"/>
</log>
</inSequence>
</target>
<parameter name="transport.PollInterval">1</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///after</parameter>
<parameter name="transport.vfs.FileURI">file:///process</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
and my "write" sequence look like this :
<sequence name="write">
<property name="transport.vfs.ReplyFileName"
expression="get-property('filename')"
scope="transport"/>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint name="FileEpr">
<address uri="vfs:file:///Target"/>
</endpoint>
</send>
When I tried this proxy and sequence, the send mediator success to create a file in the "target" folder, but the problem is the content of the file is not written. So the size is 0 byte. My original file is 1000bytes. If I add this config in the sequence
<log level="full"/>
it works perfectly fine. My question is, do I need to use the log full config? but when I look at the File Processing sample in WSO2 web it doesn't use any log full config. So how can I use send mediator to write file without using any "log" property?
Thanks,

Related

How do I transfer files from server to server using wso2 vfs?

I have created a wso2 file transfer service which transfers files from one folder to another on my local machine, this is done using a proxy and a sequence on integration studio, I then export a carbon application and deploy it on enterprise integrator. However, the moment I try to transfer files from server to server or from folder to folder within the same server the files do not transfer even though there are no errors in the error log. I have created my own FTP server using iis. I have also encoded the FTP file path. Please see my proxy and sequence below, any help will be greatly appreciated.
Proxy service,
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="YenloProxy" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<log level="custom">
<property name="sequence" value="Proxy"/>
</log>
<clone>
<target sequence="YenloSequence"/>
</clone>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.PollInterval">15</parameter>
<parameter name="transport.vfs.FileURI">vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FIncoming%2F</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterFailure">vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FFailure%2F</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.dat</parameter>
<parameter name="transport.vfs.MoveAfterProcess">vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FOutgoing%2F</parameter>
</proxy>
Sequence,
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="YenloSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="custom">
<property name="sequence" value="YenloSequence"/>
</log>
<property expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.txt')" name="transport.vfs.ReplyFileName" scope="transport" type="STRING"/>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="ClientApiNonBlocking" scope="axis2" type="STRING" value="true"/>
<send>
<endpoint name="FileEpr">
<address uri="vfs:ftp://ftp-user%3AP%40ssw0rd01%40192.168.1.36%3A21%2FOutput%2F">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
</send>
</sequence>
In the proxy service, the transports attribute is used to define the transport protocols that are used to receive messages. Since we are using VFS Transport to receive the file, you need to set the value of the transport as follows, transports="vfs". You may refer to this example for more information.

File Processing :Have issues while File proceesing in wso2

Respected Sir,
I have to process only the files which are coming to the folder newly ( there could be files which are already existing in the folder which should not be picked for processing )
The client does not want to move the files to another folder after processing. So if the file remains in the same folder after processing. They should not be re-processed and should remain in the same folder with same extension
Below is the code I am trying. But I am not able to achieve above .Please guide.
<?xml version="1.0" encoding="UTF-8"?>
<proxy name`enter code here`="FlatFileProxy" startOnLoad="true" transports="vfs" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
<property name="REST_URL_POSTFIX" scope="axis2" type="STRING" value=""/>
<property action="remove" name="ClientApiNonBlocking" scope="axis2"/>
<datamapper config="gov:datamapper/xmlToCsv1.dmc" inputSchema="gov:datamapper/xmlToCsv1_inputSchema.json" inputType="XML" outputSchema="gov:datamapper/xmlToCsv1_outputSchema.json" outputType="CSV"/>
<property expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.csv')" name="transport.vfs.ReplyFileName" scope="transport" type="STRING"/>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="messageType" scope="axis2" type="STRING" value="application/csv"/>
<property action="remove" name="LAST_MODIFIED" scope="transport"/>
<send>
<endpoint>
<address uri="vfs:file:///C:/Flatfile/output"/>
</endpoint>
</send>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.vfs.Streaming">true</parameter>
<parameter name="transport.PollInterval">50ms</parameter>
<parameter name="transport.vfs.ContentType">application/xml</parameter>
<parameter name="transport.vfs.FileURI">file:///C:/Flatfile/input1</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///C:/Flatfile/failure</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.FileNamePattern">.*\.xml</parameter>
<parameter name="transport.vfs.Locking">disable</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///C:/Flatfile/orgFilesProcessedSuccessfully</parameter>
</proxy>
With Regards,
Aditya
With vfs Transport you have the option to use transport.vfs.ActionAfterProcess NONE. But then you'll have to find a way in your inSequence to find a way to not process file that was already processed (maybe based on file date with get-property('transport', 'LAST_MODIFIED')).
Take care on the sorting in this case to process the last file first (transport.vfs.FileSortAttribute = Lastmodifiedtimestamp and transport.vfs.FileSortAsscending = false)

How to keep file after being processed in source folder vfs transport WSO2

I use VFS transport in WSO2 to route file from one folder to another. But now I'm facing a problem, I do not want to move the processed file to another folder or delete it. The problem is VFS transport has a default action DELETE or move processed file to another folder. Is it possible to keep the processed file in the source folder? Or do I have to change the code or modify something else? Is there any other way to do this?
FYI, my proxy looks like this,
<proxy name="XXX" transports="vfs" startOnLoad="true" trace="disable">
<description/>
<target>
<inSequence>
<class name="com.test.read"/>
<log level="custom">
<property name="status" value="file read"/>
</log>
</inSequence>
</target>
<parameter name="transport.PollInterval">1</parameter>
<parameter name="transport.vfs.FileURI">file:///source</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///target</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
After the file is processed, the file will be moved to folder target. So how can I keep the file without moving or delete it?
Thanks :)
Just change the transport.vfs.MoveAfterProcess to original location, which will keep the file there even after being processed.
<proxy name="XXX" transports="vfs" startOnLoad="true" trace="disable">
<description/>
<target>
<inSequence>
<class name="com.test.read"/>
<log level="custom">
<property name="status" value="file read"/>
</log>
</inSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">1</parameter>
<parameter name="transport.vfs.FileURI">file:///source</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///source</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
</proxy>

JMS Not working in Wso2Esb 4.7.0

i am working with wso2esb 4.7.0 and ActiveMQ5.8.0 whenever i am working with wso2esb4.6.0 and ActiveMQ5.5.1 its working fine i am publishing my configuration below any one help for this
message store
<messageStore xmlns="http://ws.apache.org/ns/synapse"
class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore"
name="JMSQueue">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
<parameter name="store.jms.destination">JMS_Reading_Queue</parameter>
</messageStore>
message processor
<messageProcessor xmlns="http://ws.apache.org/ns/synapse"
class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor"
name="faisal"
messageStore="JMSQueue">
<parameter name="max.delivery.attempts">4</parameter>
<parameter name="interval">1000</parameter>
</messageProcessor
and proxy is like this
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Jms"
transports="https http jms"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<log level="full"/>
<store messageStore="JMSQueue"/>
<property name="target.endpoint"
value="JmsEndpoint"
scope="default"
type="STRING"/>
</inSequence>
<outSequence/>
</target>
</proxy>
and i defined my endpoint in endpoints
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="JmsEndpoint">
<address uri="http://192.168.1.122:8282/services/ReadingsMobile"
format="soap11"/>
</endpoint>
now i am getting no target endpoint errors same configuration working in wso2esb4.6.0 mbut not working in wso2esb4.7.0
and its giving errors like this
[2013-08-21 16:48:32,049] WARN - ForwardingHandler Property target.endpoint not found in the message context. Removing the message.
[2013-08-21 16:49:32,093] WARN - SourceHandler Connection time out after request is read: http-incoming-13
Try doing the below modifications in the proxy configuration in order to get rid of the warnings;
a) Replace < target > with < target endpoint="JmsEndpoint" >
b) Move the "store" tag entry after the property where you set the "target.endpoint".
These changes seem to do the trick in my environment. Check if it fixes your issue too.
Hope this helps.
Basically the error you are getting says message processor cannot find the target.endpoint property from the stored message context.
The reason for this is, you are storing the message before setting this property.
You have to set the 'target.endpoint' property before the store mediator in the flow.
Proxy configuration should look likes follows.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Jms"
transports="https http jms"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<log level="full"/>
<property name="target.endpoint"
value="JmsEndpoint"
scope="default"
type="STRING"/>
<store messageStore="JMSQueue"/>
</inSequence>
<outSequence/>
</target>
</proxy>

How to store the Messages In JMS Queue Using Wso2esb and Activemq

I am using wso2esb4.7.0 and ActiveMQ5.8.0 i wish to store the messages in Queue
for this i try with this code but its not working
i created store which will helpful for storing the messages,my conumeing process has done in JAVA code so i need not worry about the Consuming
if i do it my message will appear in acivemq UI
my config is like this
<messageStore name="JMSQueue" class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
<parameter name="store.jms.destination">faisal5_Queue</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
</messageStore>
and i am trying to pass the message through the proxy for that i write simple proxy service for that
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Jms"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<log level="full"/>
<property name="OUT_ONLY" value="true"/>
<store messageStore="JMSQueue"/>
</inSequence>
<outSequence/>
</target>
<description/>
</proxy>
in this case my queue is not creating in Activemq Why its happening
if i create message process then only my QUEUE is appearing in ActiveMQ UI
will you write sample code for this my scenario is simple i wsih to store my client messages without failure they will consume after the storing process
Your proxy and message store are okay, I tested those.
I think you have not correctly Configure the ESB with ActiveMQ.
Follow this link and place the jars as mentioned and edit the Axis2.xml. Then try with your code. It should work
You can simply use the below config to store messages in activemq.
Since you are not using a message processor, it is no need of making a message store. So you can simple store messages in the queue as follows.
<proxy name="JmsProxyTest"
transports="https http"
startOnLoad="true"
trace="disable">
<target endpoint="jmsEndpoint">
<inSequence>
<property name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
</inSequence>
<outSequence>
<drop/>
</outSequence>
</target>
<endpoint name="jmsEndpoint">
<address uri="jms:/faisal5_Queue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://127.0.0.1:61616&transport.jms.DestinationType=queue"/>
Also you better check you have configured activemq with esb correctly.
Thanks.