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

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.

Related

Guaranteed Delivery of Messages with Active MQ and WSO2 EI

Issue: i have a proxy service which consumes only XML message, but sometimes if we are getting XML message with not proper format,just syntax error,our proxy should send that message to a different queue,the message should not loss.
i have followed the below link but unable to get the expected output
https://www.yenlo.com/blog/guaranteed-message-deliveries-part-3-monitoring-the-redelivery-policy
Below is my proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="RollbackProxy" startOnLoad="true" transports="jms" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<log description="" level="full">
<property name="****************" value="******************************"/>
</log>
</inSequence>
<outSequence/>
<faultSequence>
<property name="SET_ROLLBACK_ONLY" scope="axis2" type="STRING" value="true"/>
<log category="ERROR" level="full">
<property expression="$ctx:ERROR_CODE" name="error_code"/>
<property expression="$ctx:ERROR_MESSAGE" name="error_message"/>
<property expression="$ctx:ERROR_DETAIL" name="error_detail"/>
</log>
</faultSequence>
</target>
<parameter name="transport.jms.Destination">QueueName</parameter>
<parameter name="transport.jms.ContentType">
<rules xmlns="">
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
</proxy>
axis2.xml and activemq.xml i have properly updated.
we are using active MQ.
Can somebody guide me on this?
Thanks in Advance

wso2/synapse service chaining: assign response from SOAP request as intput to another request

My desired sequence is the following:
Read message from queue
Transform
Make an SOAP call
Output SOAP response to another queue
Steps 1,2,3 work fine but when the message sent in Step 4, that I'm intending to contain the SOAP response, is empty. What am I doing wrong?
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JmsToWsdlJms" transports="https,http,jms" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<enrich>
<source type="body" clone="true"/>
<target type="property" property="jms_body_text"/>
</enrich>
<property name="jms_body_text"
expression="get-property('jms_body_text')"
scope="default"/>
<xslt key="jmsMsgToSoapMsg_xslt">
<property name="jms_text" expression="get-property('jms_body_text')"/>
</xslt>
<log level="full">
<property name="After transformation" value="****"/>
</log>
<send>
<endpoint key="axisStockQuote"/>
</send>
<log level="full">
<property name="After callout" value="****"/>
</log>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint key="jmsQueue2"/>
</send>
</inSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>text/plain; charset=ISO-8859-1</default>
</rules>
</parameter>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.Destination">cn=tro_Q_JMS1</parameter>
</proxy>
You can use 'send receive' instead of the send mediator. Something like,
<send receive="jmsQueue2Sequence">
<endpoint key="axisStockQuote"/>
</send>
So that the response of axisStockQuote will be sent to the jmsQueue2Sequence. Refer [1] for more info.
[1] https://docs.wso2.com/display/ESB481/Send+Mediator

Send Mediator with VFS error WSO2 ESB

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,

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 do I return a response in an wso2 esb proxy with vfs JMS Sender?

I have a proxy service in WSO2 ESB 4.5.0 that is supposed to handle a SOAP-request from a webclient, send information to a JMS-topic and then respond to the the webclient.
The problem is that when I use the JMS-sender it by default waits for a response on a temporary queue.
To change the behavior of the JMS-Sender I can set OUT_ONLY to true, but then the webclient does not get a response at all.
Is there a way to return a response even if I set OUT_ONLY to true?
OR
Can I set JMS-Sender not to expect a reply without sending OUT_ONLY to true?
According to your requirement you may need to use a Messagestore, please refer the following configuration, which stores the message in JMSStore and sending the acknowledgement back to the client (success or failed),followed by ESB uses the forward schedul processor which guarantees that the store message in the JMSStore will be delivered to the backend, and in the case of the real BE (may be JMS) failed it retires thus util the message is delivered thus it wont be removed from the Message store, this a part how the DEAD LATTER CHANNELING has been accomplished using WSO2 ESB
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true"/>
<property name="target.endpoint" value="JMSEP"/>
<property name="enableREST" value="true"/>
<store messageStore="JMSMS"/>
<payloadFactory>
<format>
<esbResponse xmlns="">
<text> added sccuessfully </text>
</esbResponse>
</format>
</payloadFactory>
<header name="To" action="remove"/>
<property name="RESPONSE" value="true" scope="default" type="STRING"/>
<send/>
</inSequence>
<faultSequence>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/>
<reason value="test"/>
<role>MessageStoreFault</role>
<detail>MessageStoreFault</detail>
</makefault>
<send/>
</faultSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
<description></description>
</proxy>
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="JMSEP">
<address uri="jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616" format="pox">
<suspendOnFailure>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
<retryDelay>0</retryDelay>
</markForSuspension>
<timeout>
<duration>1000</duration>
<responseAction>fault</responseAction>
</timeout>
</address>
</endpoint>
<messageStore name="JMSMS" 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">JMSMS</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
</messageStore>
<messageProcessor name="Processor1" class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor" messageStore="JMSMS" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="interval">4000</parameter>
</messageProcessor>