WSO2 VFS FTP Proxy create dynamically - wso2

At the moment, I am creating VFS Proxy services in WSO2 manually.
But I need to create services like this based on user input. There is no problem in generating a required XML. But I yet to find a way to dynamically import those XML into WSO2.
Does anyone know a way to make this work without manual service creation?
An example service:
<?xml version="1.0" encoding="UTF-8"?><proxy xmlns="http://ws.apache.org/ns/synapse" name="FileProxy" startOnLoad="true" statistics="disable" trace="disable" transports="vfs">
<target>
<inSequence>
<log level="full"/>
<clone>
<target sequence="fileWriteSequence"/>
</clone>
</inSequence>
</target>
<parameter name="transport.PollInterval">15</parameter>
<parameter name="transport.vfs.FileURI">file:///in</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///out/out</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///out/out</parameter>
<description/>
</proxy>

There are several ways to achive this.
1.) Use the admin services to create a proxy, that´s what we are doing for a couple of years now without problems
https://docs.wso2.com/display/EI630/Working+with+Admin+Services
2.) Just generate a XML file (like above) in the directory ESB_HOME/repository/deployment/server/synapse-configs/default/proxy-services
Regards
Martin

Related

Messages are vanishing after restarting WSO2 Server

I am using WSO2 ESB 5.0.0 and Apache activeMQ 5.14 for my project.I am using jms proxy which is listening to a queue and the proxy is using jms message store to store the messages.And there is a message processor which will pick up those messages from that message store for further processing.
But after restarting WSO2 server the messages which were stuck at the queue are getting dequeued and vanished.
Is there any way to store those messages by WSO2?
Here is my proxy service:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="abcMQ"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="jms">
<target>
<inSequence>
<log level="full" separator="**Consumed from abc IN Seq**"/>
<property name="DISABLE_CHUNKING"
scope="axis2"
type="STRING"
value="true"/>
<store messageStore="TEST"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
<parameter name="transport.jms.Destination">req.Q</parameter>
<parameter name="transport.jms.ContentType">application/XML</parameter>
<description/>
</proxy>
The message store TEST is below:
<messageStore name="TEST" class="org.apache.synapse.message.store.impl.jms.JmsStore" 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">TEST.Q</parameter>
<parameter name="store.jms.username">admin</parameter>
<parameter name="store.jms.password">admin</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
<parameter name="store.producer.guaranteed.delivery.enable">true</parameter>
<parameter name="store.failover.message.store.name">fail</parameter>
</messageStore>
The fail message store is:
<messageStore name="fail" class="org.apache.synapse.message.store.impl.jms.JmsStore" 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">fail.Q</parameter>
<parameter name="store.jms.username">admin</parameter>
<parameter name="store.jms.password">admin</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
<parameter name="store.producer.guaranteed.delivery.enable">false</parameter>
<parameter name="store.failover.message.store.name">fail</parameter>
</messageStore>
Message processor is:
<messageProcessor name="TestProcessor" class="org.apache.synapse.message.processor.impl.sampler.SamplingProcessor" messageStore="TEST" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="interval">1000</parameter>
<parameter name="concurrency">1</parameter>
<parameter name="sequence">DemoSequence</parameter>
<parameter name="is.active">true</parameter>
</messageProcessor>
Since the in-memory message stores uses an in-memory queue to store the messages, the messages will be lost in case of a restart or shutdown.
That's why its use is not recommended for Production systems or large scale message processing systems. You can view the recommendation here.
Consider using other forms of message stores for better reliability and guaranteed delivery. Refer the following options:
https://docs.wso2.com/display/ESB500/Adding+a+Message+Store
Also consider using a fail-over message store for better reliability.
https://docs.wso2.com/display/ESB500/Guaranteed+Delivery+with+Failover+Message+Store+and+Scheduled+Failover+Message+Forwarding+Processor

WSO2 ESB MailTransportListener not receiving

I just installed my brand new WSO2 ESB 4.9.0. This is the latest version which I downloaded yesterday.
I am trying to get my ESB to receive e-mail from a server. I have tried POP3 and IMAP. I have been using several references to help me(Since I am a new member, my reputation does not yet allow me to post proper links to all my references):
stackoverflow.com/questions/27376833/wso2-mailto-transport-emptied-my-inbox
javamail.java.net/nonav/docs/api/com/sun/mail/pop3/package-summary.html
javamail.java.net/nonav/docs/api/com/sun/mail/imap/package-summary.html
sparkletechthoughts.blogspot.fr/2013/10/how-to-receive-emails-to-wso2-esb.html
charithaka.blogspot.com/2012/11/how-to-enable-mail-transport-for-wso2.html
irhamiqbal.wordpress.com/how-to-receive-email-using-wso2-esb/
jayalalk.blogspot.com/2014/06/wso2-esb-mail-sending-with-html-complex.html
And of course the official documentation:
https://docs.wso2.com/display/ESB481/MailTo+Transport
https://docs.wso2.com/display/AS501/Using+Mail+transport+to+Invoke+Web+Services
All of my reading leads me to believe that I have everything set up properly (or if not properly, good enough to get some error messages to troubleshoot).
I did restart the WSO2 ESB and the following message shows up in the console log:
TID[-1234] [ESB] [2016-08-02 21:45:37,237] INFO {org.apache.axis2.transport.mail.MailTransportListener} - MAILTO listener started
I get no other indication in the logs one way or another.
I edited (and double checked) my $CARBON_HOME/repository/conf/axis2/axis2.xml, and I'm pretty sure I have the mail transport enabled properly:
<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.MailTransportListener">
<!-- configure any optional POP3/IMAP properties
check com.sun.mail.pop3 and com.sun.mail.imap package documentation for more details-->
</transportReceiver>
<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
<parameter name="mail.smtp.host">my.smtp.server</parameter>
<parameter name="mail.smtp.port">587</parameter>
<parameter name="mail.smtp.starttls.enable">false</parameter>
<parameter name="mail.smtp.auth">true</parameter>
<parameter name="mail.smtp.user">my#user.id</parameter>
<parameter name="mail.smtp.password">password</parameter>
<parameter name="mail.smtp.from">my#email.com</parameter>
</transportSender>
And, finally, I have my Proxy Service setup (in its current iteration, anyway):
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JasperEmailPOP3"
transports="mailto"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="senderAddress"
expression="get-property('transport', 'From')"
scope="default"
type="STRING"/>
<log level="custom">
<property name="Date" expression="$trp:Date"/>
<property name="Subject" expression="$trp:Subject"/>
<property name="Content-Type" expression="$trp:Content-Type"/>
<property name="From" expression="$trp:From"/>
</log>
<drop/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<parameter name="mail.pop3.socketFactory.class">javax.net.ssl.SSLSocketFactory</parameter>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="mail.pop3.host">my.pop3.email</parameter>
<parameter name="mail.pop3.user">my#email.com</parameter>
<parameter name="transport.mail.Protocol">pop3</parameter>
<parameter name="mail.pop3.socketFactory.port">995</parameter>
<parameter name="transport.mail.Address">jasper#eryjus.com</parameter>
<parameter name="mail.pop3.password">password</parameter>
<parameter name="mail.pop3.port">995</parameter>
<parameter name="mail.pop3.socketFactory.fallback">false</parameter>
<description/>
</proxy>
With all of this, my question is: is there something else I am missing to get the ESB to at least attempt to retrieve e-mail? What bothers me is I am not getting any error messages to troubleshoot (such as my mail not being in plain test).
I tried the same scenario with a Gmail account and it works fine for me, seems like some mis-configuration in your POP server. You need to add following property as well.
<parameter name="transport.mail.ContentType">text/plain</parameter>
See the full proxy configs below.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JasperEmailPOP3"
transports="mailto"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="senderAddress"
expression="get-property('transport', 'From')"
scope="default"
type="STRING"/>
<log level="custom">
<property name="Date" expression="$trp:Date"/>
<property name="Subject" expression="$trp:Subject"/>
<property name="Content-Type" expression="$trp:Content-Type"/>
<property name="From" expression="$trp:From"/>
</log>
<drop/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<parameter name="mail.pop3.socketFactory.class">javax.net.ssl.SSLSocketFactory</parameter>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="mail.pop3.host">pop.gmail.com</parameter>
<parameter name="mail.pop3.user">ycwso2test</parameter>
<parameter name="transport.mail.Protocol">pop3</parameter>
<parameter name="mail.pop3.socketFactory.port">995</parameter>
<parameter name="transport.mail.Address">ycwso2test#gmail.com</parameter>
<parameter name="mail.pop3.password">wso2qa123</parameter>
<parameter name="mail.pop3.port">995</parameter>
<parameter name="mail.pop3.socketFactory.fallback">false</parameter>
<parameter name="transport.mail.ContentType">text/plain</parameter>
<description/>
</proxy>
Also if you need to further debug this you can enable DEBUG logs. To do this add the following line to repository/conf/log4j.properties and restart.
log4j.logger.org.apache.axis2.transport.mail.MailTransportListener=DEBUG

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>

use vfs in wso2 esb?

I create a proxy service that transform file new text document.txt from ///d:test/orginal
to ///d:test/pass in local
My proxy code is:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testVFS"
transports="https,http,local"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<address uri="https://127.0.0.1:9443/services/SimpleStockQuoteService?wsdl"/>
</endpoint>
</target>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.FileURI">file:///D:/test/Orginal/</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///D:/test/Pass/</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///D:/test/Failures/</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
<parameter name="transport.vfs.ContentType">text/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<description/>
</proxy>
But I have an error and not transform files:
<TryitProxyError xmlns:h="http://wso2.org/ns/TryitProxy" h:status="SOAP envelope error">org.apache.axis2.AxisFault: Read timed out</TryitProxyError>
Thanks
In your proxy your transports are set as:
transports="https,http,local"
Changing this to
transports="vfs"
will ensure it tries to use the VFSTransportListener.
Just make sure that the following line is not commented in %ESB_HOME%\repository\conf\axis2\axis2.xml:
<transportReceiver class="org.apache.synapse.transport.vfs.VFSTransportListener" name="vfs"/>
You must use vfs transport. To understand how to use refer http://docs.wso2.org/display/ESB470/VFS+Transport and http://docs.wso2.org/pages/viewpage.action?pageId=26838852
The problem is related to the SoapAction endpoint.
Example using:
<header name="Action" value="urn:mediate"/>
<send>
<endpoint key="SimpleStockQuoteService"/>
</send>

WSO2 ESB Web destroys nice synapse XML structure

We developed our proxies, sequences and so on with a XML editor and had a very good structure of the synapse configurations, but as we open the component with the web interface and the whole code is realigned and changed.
Is there a way to see the content of the components with the web without destroying the whole structure?
This here was our code:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="patient_toMPI_pJMS_qToMPIXml" statistics="disable" trace="disable" transports="jms">
<parameter name="transport.jms.Destination">queueName</parameter>
<parameter name="transport.jms.ConnectionFactory">queueBlocking</parameter>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<target faultSequence="rollbackSequence">
<inSequence>
<property name="frameworkContext" expression="get-property('default', 'frameworkContext')" scope="transport"/>
<property name="frameworkMessageId" expression="get-property('default', 'frameworkMessageId')" scope="transport"/>
<property name="frameworkTransactionId" expression="get-property('default', 'frameworkTransactionId')" scope="transport"/>
</inSequence>
</target>
After opening just once with the web interface it looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="patient_toMPI_pJMS_qToMPIXml"
transports="jms"
startOnLoad="true"
trace="disable">
<target faultSequence="rollbackSequence">
<inSequence>
<property xmlns:urn="urn:hl7-org:v2xml"
xmlns:hl7="http://wso2.org/hl7"
name="frameworkContext"
expression="get-property('default', 'frameworkContext')"
scope="transport"/>
<property xmlns:urn="urn:hl7-org:v2xml"
xmlns:hl7="http://wso2.org/hl7"
name="frameworkMessageId"
expression="get-property('default', 'frameworkMessageId')"
scope="transport"/>
<property xmlns:urn="urn:hl7-org:v2xml"
xmlns:hl7="http://wso2.org/hl7"
name="frameworkTransactionId"
expression="get-property('default', 'frameworkTransactionId')"
scope="transport"/>
</inSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.ConnectionFactory">queueBlocking</parameter>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.Destination">queueName</parameter>
</proxy>
Is this a bug within WSO2? Is it configurable?
I don't see much change done in your configuration. Properties are pushed down to the bottom (thats the only change I see) and thats the normal behaviour in WSO2 ESB.
There is no way to view the source without using the web console (unless you view it from the file system).