Wso2 mailto transport emptied my Inbox - wso2

I was working with the wso2 esb mail transport. I configured my mail id and all the details in the axis2.xml. When I restarted the Wso2 esb, I found that my Inbox is emptied.
Here is my axix2.xml:
<!-- ================================================= -->
<!-- Transport Ins (Listeners) -->
<!-- ================================================= -->
<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>
<!-- ================================================= -->
<!-- Transport Outs (Senders) -->
<!-- ================================================= -->
<!-- Uncomment and configure the SMTP server information
check com.sun.mail.smtp package documentation for descriptions of properties-->
<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
<parameter name="mail.smtp.host">mum.*******.com</parameter>
<parameter name="mail.smtp.port">587</parameter>
<parameter name="mail.smtp.starttls.enable">true</parameter>
<parameter name="mail.smtp.auth">true</parameter>
<parameter name="mail.smtp.user">*******</parameter>
<parameter name="mail.smtp.password">*********</parameter>
<parameter name="mail.smtp.from">*******#*****.com</parameter>
</transportSender>
Here is my proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="MailSample"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<log>
<property name="hii" value="hi************************"/>
</log>
<property name="senderAddress" expression="get-property('transport', 'From')"/>
<log level="full">
<property name="Sender Address" expression="get-property('senderAddress')"/>
</log>
<send>
<endpoint>
<address uri="mailto:janiyani.richa#gmail.com"/>
</endpoint>
</send>
</inSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.Destination">mailSender</parameter>
</proxy>
Do you know where did my mails go?
Is it possible to retrieve the mails?
Thanks in Advance.

By default, most POP3 mail servers keep messages only until they are downloaded by the mail client and then those are deleted. So the above behaviour can be due to that reason and you can prevent this from happening by doing the necessary configurations to leave the messages on server without deleting them even after they are read.
For setting this property at the client (axis2) side, see the mail.pop3.rsetbeforequit property in the com.sun.mail.pop3 documentation available here. (Also depending on the server, there can be server side configurations instead that will make sure that mails will always be kept at the server after being read.)

Related

WSO2 - EI 6.2.0 - Configuring Oracle AQ JMS database with EI to publish/consume messages to/from Oracle AQ JMS

This is Radhakrishnan and new to WSO2 world. Would like to configure the Oracle AQ JMS with EI so that EI can consume/publish messages from Oracle AQ JMS.
Configuration for axis2.xml has been done and written a Proxy to consume message from Oracle AQ JMS.
Now when we are publishing to Oracle AQ JMS we are getting below error and anybody has suggestion/valuable inputs?
Caused by: javax.naming.NameNotFoundException: Name [dynamicQueues//RIB_AQ_USER.ETEXTPAYTERM] is not bound in this Context. Unable to find [dynamicQueues].
at org.apache.naming.NamingContext.lookup(NamingContext.java:825)
at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
at org.wso2.carbon.context.internal.CarbonContextDataHolder$CarbonInitialJNDIContext.lookup(CarbonContextDataHolder.java:709)
Here is the code snippet:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="RMSPayTermOutToRMSProxy"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<log level="full"/>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
<send>
<endpoint>
<address format="pox"
uri="jms2:/RIB_AQ_USER.ETEXTPAYTERM?transport.jms.ConnectionFactoryJNDIName=JMSSenderTopicConnectionFactory"/>
</endpoint>
</send>
</inSequence>
</target>
<parameter name="serviceType">proxy</parameter>
<description/>
</proxy>
I have faced a similar problem a year ago, and we fixed using the below configurations.
We have configured the Connection Factory(AqQueueConnectionFactory) in axis2.xml
<!-- Oracle AQ Listener Start-->
<transportReceiver name="oracleaq" class="org.apache.axis2.transport.jms.JMSListener">
<parameter name="AqQueueConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">oracle.jms.AQjmsInitialContextFactory</parameter>
<parameter name="db_url" locked="false">jdbc:oracle:thin:#hostname:port:schema</parameter>
<parameter name="java.naming.security.principal" locked="false">username</parameter>
<parameter name="java.naming.security.credentials" locked="false">password</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
</parameter>
<parameter name="AqTopicConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">oracle.jms.AQjmsInitialContextFactory</parameter>
<parameter name="db_url" locked="false">jdbc:oracle:thin:#hostname:port:schema</parameter>
<parameter name="java.naming.security.principal" locked="false">username</parameter>
<parameter name="java.naming.security.credentials" locked="false">password</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
</parameter>
</transportReceiver>
<!-- Oracle AQ Listener End -->
We have to restart the server after changing the axis2.xml and adding the following jar file (aqapi-10.1.3.1.jar and its dependencies) in the lib folder.
In the Proxy, Parameters section, we defined the Queue configuration to which the Proxy listens to.
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.Destination">Queues/QueueName</parameter>
<parameter name="transport.jms.ContentType">
<rules xmlns="">
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.ConnectionFactory">AqQueueConnectionFactory</parameter>
AS stated above in the axis2.xml, we enabled the oracleaq as one if the transport of the proxy.
Once the above setup is done, we can listen to the queues/topics from Oracle AQ without any issues.
Thanks.

wso2 EI 611 ActiveMQ

Declared Message store in ESB
<?xml version="1.0" encoding="UTF-8"?>
<messageStore class="org.apache.synapse.message.store.impl.jms.JmsStore" name="MySQLStockAdjustment" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="store.jms.destination">MySQLStockAdjustment</parameter>
<parameter name="store.failover.message.store.name">MySQLStockAdjustmentFailover</parameter>
<parameter name="store.jms.connection.factory">myQueueConnectionFactory</parameter>
<parameter name="store.producer.guaranteed.delivery.enable">true</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
<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.JMSSpecVersion">1.1</parameter>
</messageStore>
and I just want for beginning to store the mesage in it and than use a proxy to read messages form it ..
proxy is simple
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="stockAdjustment" startOnLoad="true" transports="jms" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<!-- get all data -->
<sequence key="AdjustmentContext"/>
<filter regex="MySQL" source="$ctx:StockSource">
<then>
<iterate expression="//request">
<target>
<sequence>
<property expression="//qty" name="qty" scope="default" type="STRING"/>
<property expression="//code" name="code" scope="default" type="STRING"/>
<log level="custom">
<property expression="fn:concat('parmams:Code: ' ,$ctx:code, ' ;Qty: ',$ctx:qty)" name="info"/>
</log>
<call blocking="true">
<endpoint key="StockAdjustmentEp"/>
</call>
</sequence>
</target>
</iterate>
</then>
<else/>
</filter>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence>
</faultSequence>
</target>
<parameter name="transport.jms.Destination">MySQLStockAdjustment</parameter>
<parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
</proxy>
so when I send a data message trough Postman Im getting the following:
WARN {org.apache.axis2.transport.jms.JMSUtils} - Can't determine size of JMS message; unsupported message type : org.apache.activemq.command.ActiveMQObjectMessage {org.apache.axis2.transport.jms.JMSUtils}
ERROR {org.apache.axis2.transport.base.BaseUtils} - Unsupported JMS message type org.apache.activemq.command.ActiveMQObjectMessage {org.apache.axis2.transport.base.BaseUtils}
ERROR {org.apache.axis2.transport.jms.JMSMessageReceiver} - Unknown error processing message {org.apache.axis2.transport.jms.JMSMessageReceiver}
message is
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<StockAdjRequest>
<source>MySQL</source>
<request><qty>2</qty><code>PR2</code></request>
<request><qty>2</qty><code>PR2</code></request>
<request><qty>2</qty><code>PR2</code></request>
</StockAdjRequest>
</soapenv:Body>
</soapenv:Envelope>
I see that message ended in queue but I can't read it trough ActiveMQ web console ...
I documentation I found that maybe a proble that I need to "...If you are using ActiveMQ 5.12.2 and above when working with message stores, you need to set the following system property on server start up for the JMS message store of the ESB Profile to work as expected.
-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*" ...."
BUt I dont found HOW to do it ... can anyone help me ?
When you store a message in a JMS queue defining a messageStore and using store mediator, you don't just store the "textual" payload from the message, but the entire java MessageContext object is serialized and store as a binary message in the queue.
To read such a message, you need to use a message processor, you can't read it with a simple JMS proxy or even jms inbound endpoint.
And you can't read it with ActiveMQ console because it can't deserialize it

Email receiver proxy in wso2 esb 5.0.0 is not working

I have created email receiver proxy in WSO2-ESB5.0, proxy is connecting to email box and and I am seeing text in the logs "Processing message # : 1 in same thread".
But nothing is getting printed in the body of the proxy where I am expecting proxy should read the email body and pass to insequence of the proxy.
And also emails are not MOVED OR DELETED when I set the properties ActionAfterProcess to MOVE/DELETE.
I see some issues here
you have in one hand
<parameter name="transport.mail.ActionAfterFailure">DELETE</parameter>
<parameter name="transport.mail.ActionAfterProcess">DELETE</parameter>
and on another hand you try to move to a folder after process or failure
<parameter name="transport.mail.MoveAfterFailure">Inbox/Failed</parameter>
<parameter name="transport.mail.MoveAfterProcess">Inbox/Processed</parameter>
So either you should remove all those four lines (default behaviour is "REMOVE") or change to
<parameter name="transport.mail.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.mail.ActionAfterProcess">MOVE</parameter>
In order to move processed files
Fetch size sounds really small to me, could you try a higher value like
<parameter name="mail.imap.fetchsize">1024</parameter>
Then I assume Inbox/TestInbox is existing and you successfully connect to the mailbox. Are you sure that the message content type is application/xml (could you simply use plain/text for instance).
Could you also try
<property name="senderAddress" expression="get-property('transport', 'From')"/>
<log level="custom">
<property name="Sender Address" expression="get-property('senderAddress')"/>
</log>
To see if you can get the sender address.
Here is sample of my proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="MailTransportProtocolIMAP"
transports="mailto"
startOnLoad="true"
statistics="enable"
trace="enable">
<description/>
<target>
<inSequence>
<log level="full">
</log>
<log category="ERROR">
<property name="emailBody" expression="$body/*"/>
</log>
<drop/>
</inSequence>
<outSequence>
<log category="ERROR">
<property name="emailBody" expression="$body/*"/>
</log>
<send/>
</outSequence>
</target>
<parameter name="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</parameter>
<parameter name="mail.imap.starttls.enable">false</parameter>
<parameter name="transport.mail.ContentType">application/xml</parameter>
<parameter name="mail.imap.host">outlook.74.net</parameter>
<parameter name="transport.mail.Address">abc#abc.com</parameter>
<parameter name="mail.imap.user">abc123</parameter>
<parameter name="mail.imap.socketFactory.port">993</parameter>
<parameter name="transport.mail.ActionAfterFailure">DELETE</parameter>
<parameter name="transport.mail.ActionAfterProcess">DELETE</parameter>
<parameter name="transport.PollInterval">2</parameter>
<parameter name="mail.imap.port">995</parameter>
<parameter name="mail.imap.ssl.enable">false</parameter>
<parameter name="transport.mail.MoveAfterFailure">Inbox/Failed</parameter>
<parameter name="transport.mail.Folder">Inbox/TestInbox</parameter>
<parameter name="transport.mail.MoveAfterProcess">Inbox/Processed</parameter>
<parameter name="mail.imap.fetchsize">2</parameter>
<parameter name="mail.imap.socketFactory.fallback">false</parameter>
<parameter name="transport.mail.Protocol">imap</parameter>
<parameter name="mail.imap.password">abc123!</parameter>
</proxy>

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

XPath from file in VFS Transport WSO2 ESB

I want to read some values from a file that being processed by the VFS transport.
My file is :
<sales>
<header>
<source>STORE1</source>
<target>HEADOFFICE</target>
</header>
So I use a property mediator to get the value I want using XPath. But when I print that property in Log Mediator it prints nothing. My proxy look like this :
<proxy name="Try1"
transports="vfs"
startOnLoad="true"
trace="disable">
<target>
<inSequence>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="source"
expression="//header/source/text()"
scope="default"
type="STRING"/>
<log level="full">
<property xmlns:ns="http://org.apache.synapse/xsd"
name="Value_source"
expression="get-property('source')"/>
</log>
</inSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">15</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///Users/Target</parameter>
<parameter name="transport.vfs.FileURI">file:///Users/Source</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///Users/Failure</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
The log mediator result is
[2013-06-28 16:59:49,939] INFO - LogMediator Value_source=
So how can I get the values in file using XPath?
The issue is due to the ContentType set for the transport parameter:
Switch
<parameter name="transport.vfs.ContentType">text/plain</parameter>
with
<parameter name="transport.vfs.ContentType">application/xml</parameter>
since you're doing XPath operations on the message.
The problem is with the content of your file. Since it is not well-formed, the xpath expression fails. Isn't it possible for you to have the well-formed xml in the input content?
<sales>
<header>
<source>STORE1</source>
<target>HEADOFFICE</target>
</header>
</sales>