ERROR: {EmailSend} - {api:EmailMicroService} Error occurred while sending the email - wso2

Scenario
I'm sending email via an unsecure smtp server connection with the help of Email connector of wso2.
Connection
<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="unSecureConn" xmlns="http://ws.apache.org/ns/synapse">
<email.init>
<requireAuthentication>true</requireAuthentication>
<connectionType>SMTP</connectionType>
<password>XXXXX</password>
<host>smtp.XXXX.com</host>
<port>25</port>
<name>unSecureConn</name>
<username>XXXXXX</username>
</email.init>
</localEntry>
API:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/email" name="EmailMicroService" port="8290" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" uri-template="/send">
<inSequence>
<log level="full"/>
<email.send configKey="unSecureConn">
<from>{json-eval($.from)}</from>
<to>{json-eval($.to)}</to>
<subject>{json-eval($.subject)}</subject>
<content>{json-eval($.content)}</content>
<contentType>{json-eval($.contentType)}</contentType>
<attachments>{json-eval($.attachments)}</attachments>
</email.send>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
Question
I'm facing the relay access denied issue. Although our smtp server is sending emails when logged in to server's user portal. However with the wso2 connector we are facing the following issue:
[2022-11-16 13:55:17,526] ERROR {EmailSend} - {api:EmailMicroService} Error occurred while sending the email with subject hi to ayub.jamal#XXXX.com. org.wso2.carbon.connector.exception.EmailConnectionException: Error occurred while sending the email with subject hi to ayub.jamal#XXXX.com.
at org.wso2.carbon.connector.operations.EmailSend.sendMessage(EmailSend.java:116)
at org.wso2.carbon.connector.operations.EmailSend.connect(EmailSend.java:59)
at org.wso2.carbon.connector.core.AbstractConnector.mediate(AbstractConnector.java:32)
at org.apache.synapse.mediators.ext.ClassMediator.updateInstancePropertiesAndMediate(ClassMediator.java:178)
at org.apache.synapse.mediators.ext.ClassMediator.mediate(ClassMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:110)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:72)
at org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:136)
at org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:170)
at org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:93)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:110)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:72)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.api.Resource.process(Resource.java:342)
at org.apache.synapse.api.API.process(API.java:477)
at org.apache.synapse.api.AbstractApiHandler.apiProcess(AbstractApiHandler.java:93)
at org.apache.synapse.api.AbstractApiHandler.dispatchToAPI(AbstractApiHandler.java:71)
at org.apache.synapse.api.rest.RestRequestHandler.dispatchToAPI(RestRequestHandler.java:90)
at org.apache.synapse.api.rest.RestRequestHandler.process(RestRequestHandler.java:76)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:54)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:344)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:101)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:376)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:435)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:183)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 554 5.7.1 <ayub.jamal#XXXX.com>: Relay access denied
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:2079)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1301)
at javax.mail.Transport.send0(Transport.java:255)
at javax.mail.Transport.send(Transport.java:124)
at org.wso2.carbon.connector.operations.EmailSend.sendMessage(EmailSend.java:135)
at org.wso2.carbon.connector.operations.EmailSend.sendMessage(EmailSend.java:110)
... 29 more
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 554 5.7.1 <ayub.jamal#XXXX.com>: Relay access denied
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1979)
... 34 more

Try adding the following parameter to the init.
<requireTLS>false</requireTLS>
Here are all the parameters you can set for the init operation. So depending on your SMTP server, you may have to set the appropriate parameters.
<parameter name="host" description="Host name of the mail server"/>
<parameter name="port" description="The port number of the mail server"/>
<parameter name="name" description="Unique name the connection is identified by"/>
<parameter name="username" description="Username used to connect with the mail server"/>
<parameter name="password" description="Password to connect with the mail server"/>
<parameter name="connectionType" description="Email connection type (protocol) that should be used to establish the connection with the server"/>
<parameter name="readTimeout" description="The socket read timeout value"/>
<parameter name="connectionTimeout" description="The socket connection timeout value"/>
<parameter name="writeTimeout" description="The socket write timeout value"/>
<parameter name="requireTLS" description="Whether the connection should be established using TLS"/>
<parameter name="checkServerIdentity" description="Whether server identity should be checked"/>
<parameter name="trustedHosts" description="Comma separated string of trust host names"/>
<parameter name="sslProtocols" description="Comma separated string of SSL protocol"/>
<parameter name="cipherSuites" description="Comma separated string of Cipher Suites"/>
<parameter name="maxActiveConnections" description="Maximum number of active connections in the pool"/>
<parameter name="maxIdleConnections" description="Maximum number of idle connections in the pool"/>
<parameter name="maxWaitTime" description="Maximum time to wait for a pooled component to become available"/>
<parameter name="minEvictionTime" description="The minimum amount of time an object may sit idle in the pool before it is eligible for eviction"/>
<parameter name="evictionCheckInterval" description="The number of milliseconds between runs of the object evictor"/>
<parameter name="exhaustedAction" description="The behavior of the pool when the pool is exhausted."/>
<parameter name="requireAuthentication" description="Whether authentication is required for SMTP server."/>

Related

WSO2 ESB: SFTP file transfer: Could not connect to SFTP server

I am trying to transfer some files from local server to SFTP server using WSO2 Enterprise Integrator 6.3.0. I have username, SFTP location, SFTP port(990), ppk file and PassPhrase. When I tried below configuration in my Proxy service, I couldn't connect to SFTP server. It gives com.jcraft.jsch.JSchException: Auth fail error. With putty, connection works.
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="SFTPFileTransferProxy" startOnLoad="true"
trace="disable" transports="vfs" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<property expression="$trp:FILE_NAME" name="FILE_NAME"
scope="default" type="STRING"/>
<log level="custom">
<property expression="$ctx:FILE_NAME" name="FL2"/>
<property name="sequence" value="FTPProxy"/>
</log>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.PollInterval">10000ms</parameter>
<parameter name="transport.vfs.FileURI">file:///C:/files/out</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///C:/test/failure</parameter>
<parameter name="transport.vfs.SFTPIdentities">file:///C:/sftp/keys/PrivateKey_Integration.ppk</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.FileNamePattern">.*\.csv</parameter>
<parameter name="transport.vfs.MoveAfterProcess">vfs:sftp://username#sftp.XXXX.com:990/in/file/</parameter>
<parameter name="transport.vfs.SFTPIdentityPassPhrase">KEY_PASSPHRASE</parameter>
</proxy>
And the error I am getting is
[2019-02-04 12:48:31,823] [] ERROR - VFSTransportListener File object 'file:///C:/files/out/20181226FULL.csv'cloud not be moved, will remain in "locked" state
org.apache.axis2.AxisFault: Error resolving directory to move after processing : sftp://username#sftp.XXXX.com:990/in/file
at org.apache.axis2.transport.base.AbstractTransportListener.handleException(AbstractTransportListener.java:343)
at org.apache.synapse.transport.vfs.VFSTransportListener.moveOrDeleteAfterProcessing(VFSTransportListener.java:715)
at org.apache.synapse.transport.vfs.VFSTransportListener.scanFileOrDirectory(VFSTransportListener.java:504)
at org.apache.synapse.transport.vfs.VFSTransportListener.poll(VFSTransportListener.java:188)
at org.apache.synapse.transport.vfs.VFSTransportListener.poll(VFSTransportListener.java:134)
at org.apache.axis2.transport.base.AbstractPollingTransportListener$1$1.run(AbstractPollingTransportListener.java:67)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.commons.vfs2.FileSystemException: Could not connect to SFTP server at "sftp://username#sftp.XXXX.com:990/".
at org.apache.commons.vfs2.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:86)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.getFileSystem(AbstractOriginatingFileProvider.java:149)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:111)
at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:81)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:778)
at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:658)
at org.apache.synapse.transport.vfs.VFSTransportListener.moveOrDeleteAfterProcessing(VFSTransportListener.java:667)
... 8 more
Caused by: org.apache.commons.vfs2.FileSystemException: Could not connect to SFTP server at "sftp.XXXX.com".
at org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:164)
at org.apache.commons.vfs2.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:79)
... 14 more
Caused by: com.jcraft.jsch.JSchException: Auth fail
at com.jcraft.jsch.Session.connect(Session.java:519)
at com.jcraft.jsch.Session.connect(Session.java:183)
at org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:162)
... 15 more
How to connect SFTP server with SFTPIdentities?
Try Key path as below, on Windows. It works for me.
<parameter name="transport.vfs.SFTPIdentities">/sftp/keys/PrivateKey_Integration.ppk</parameter>
On Ubuntu, I am giving the key path as
<parameter name="transport.vfs.SFTPIdentities">/home/sbhatti/.ssh/key.ppk</parameter>
But it is not working, and giving the same exception as posted in question above. anyone has any idea? How we can debug and apply correct path?

Mqtt back end over websocket

We have an Mqtt broker in the back-end which is setup to accept connections over WebSocket. Everything works when I connect directly to this machine. But we would like to route all calls through Enterprise integrator. I can't seem to get this working correctly. The backend websocket listens on a path, not on the root (eg: machine:9999/api/mqtt). For testing purposes the back-end Mqtt broker has no security implemented. It accepts every connection and all can subscribe and publish.
Changes to axis.xml
<transportReceiver name="mqtt" class="org.apache.axis2.transport.mqtt.MqttListener">
<parameter locked="false" name="mqttConFactory">
<parameter locked="false" name="mqtt.server.host.name">workerv2</parameter>
<parameter name="mqtt.connection.factory">mqttConFactory</parameter>
<parameter locked="false" name="mqtt.server.port">9026</parameter>
<parameter locked="false" name="mqtt.client.id">client-id-1234</parameter>
<parameter locked="false" name="mqtt.topic.name">esb.test</parameter>
</parameter>
</transportReceiver>
<transportSender name="ws" class="org.wso2.carbon.websocket.transport.WebsocketTransportSender">
<parameter name="ws.outflow.dispatch.sequence" locked="false">outflowDispatchSeq</parameter>
<parameter name="ws.outflow.dispatch.fault.sequence" locked="false">outflowFaultSeq</parameter>
</transportSender>
I've copied the jar file into the libs folder: org.exlipse.paho.client.mqttv3-1.1.0.jar
I've setup my sequences and websocket inbound endpoint as per the example here
I don't know how to troubleshoot this, I have log4j set to show wire logs but can't seem to get any information from them. I don't see any errors, so I think I have to be close(?)
Can you help me please?
EDIT
I managed to setup the websocket to websocket connection. When connecting directly the websocket works and I can connect successfully. But when I connect through the wso2ei, I can see the log message and everything looks ok. But all requests time out after 120 seconds. I can't seem to debug headers for websockets. Any help would be appreciated.
As per example my dispatch sequence:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="dispatchSeq" xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="LOGGED_MESSAGE" value="LOGGED"/>
</log>
<send>
<endpoint>
<address uri="ws://10.100.14.8:9026/api/v2/mqtt"/>
</endpoint>
</send>
</sequence>
My out sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="outDispatchSeq" trace="enable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full"/>
<respond/>
</sequence>
My inbound endpoint
<?xml version="1.0" encoding="UTF-8"?><inboundEndpoint xmlns="http://ws.apache.org/ns/synapse" name="testMQTT" sequence="dispatchSeq" onError="fault" protocol="ws" suspend="false">
<parameters>
<parameter name="inbound.ws.port">9091</parameter>
<parameter name="ws.client.side.broadcast.level">0</parameter>
<parameter name="ws.outflow.dispatch.sequence">outDispatchSeq</parameter>
<parameter name="ws.outflow.dispatch.fault.sequence">fault</parameter>
<parameter name="ws.use.port.offset">false</parameter>
</parameters>
Log messages
TID: [-1] [] [2018-04-24 14:25:14,675] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: , MessageID: urn:uuid:decebbbe-8ad7-4174-adb9-1bc324764275, Direction: request, LOGGED_MESSAGE = LOGGED, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator}
TID: [-1] [] [2018-04-24 14:25:16,177] WARN {org.apache.synapse.core.axis2.TimeoutHandler} - Expiring message ID : urn:uuid:26b39fa8-9b5e-44cd-86b3-caa72c30047b; dropping message after GLOBAL_TIMEOUT of : 120 seconds for AnonymousEndpoint, URI : ws://10.100.14.8:9026/api/v2/mqtt, Received through Inbound Endpoint : testMQTT {org.apache.synapse.core.axis2.TimeoutHandler}
I worked arount the problem, websocket connects directly without the esb integrator.

WSO2 Enterprise Integrator v6.1.1 make lock file while moving a file using VFS

I am using WSO2 Enterprise Integrator 6.1.1 . I am using VFS to poll a file from one directory and move to another directory. But my proxy service is making a lock file, and unable to move the file. I initially thought that it is a file permission issue but when I try it with Inbound Endpoint or my custom java mediator called in a proxy service. Then file is successfully moved.
Lock File:
Proxy Service Code:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestCSVFileMoving"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="vfs">
<target>
<inSequence>
<log level="full"
separator=",========----------Test CSV File Proxy Triggered------======="/>
</inSequence>
<faultSequence/>
</target>
<parameter name="transport.vfs.Streaming">true</parameter>
<parameter name="transport.PollInterval">30</parameter>
<parameter name="transport.vfs.FileURI">vfs:file:///files/uploads</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterFailure">vfs:file:///opt/file/con/Fail</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.FileNamePattern">Test.*.csv</parameter>
<parameter name="transport.vfs.MoveAfterProcess">vfs:file:///opt/file/con/Out</parameter>
<description/>
</proxy>
Error Logs:
TID: [-1234] [] [2018-01-10 12:51:56,634] ERROR {org.apache.synapse.transport.vfs.VFSTransportListener} - File object 'file:///files/uploads/Test.csv'cloud not be moved, will remain in "locked" state {org.apache.synapse.transport.vfs.VFSTransportListener}
org.apache.axis2.AxisFault: Error moving file : file:///files/uploads/Test.csv to file:///opt/file/con/Out
at org.apache.axis2.transport.base.AbstractTransportListener.handleException(AbstractTransportListener.java:343)
at org.apache.synapse.transport.vfs.VFSTransportListener.moveOrDeleteAfterProcessing(VFSTransportListener.java:682)
at org.apache.synapse.transport.vfs.VFSTransportListener.scanFileOrDirectory(VFSTransportListener.java:499)
at org.apache.synapse.transport.vfs.VFSTransportListener.poll(VFSTransportListener.java:188)
at org.apache.synapse.transport.vfs.VFSTransportListener.poll(VFSTransportListener.java:134)
at org.apache.axis2.transport.base.AbstractPollingTransportListener$1$1.run(AbstractPollingTransportListener.java:67)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.commons.vfs2.FileSystemException: Could not rename "file:///files/uploads/Test.csv" because it is read-only.
at org.apache.commons.vfs2.provider.AbstractFileObject.moveTo(AbstractFileObject.java:1087)
at org.apache.synapse.transport.vfs.VFSTransportListener.moveOrDeleteAfterProcessing(VFSTransportListener.java:680)
... 8 more
Problem Statement:
My Question is that in the error log, it clearly states that it is a read only file. But Why that by using Inbound Endpoint and Calling a custom mediator I am able to move the file.But using VFS only I am getting this error? Also is there any way to solve it. If I have to use the VFS.

WSO2 IMB MQ connection with new created Queues

I have a question,I new in ESB so I used the manual to create connection with my ESB and IBM MQ
https://docs.wso2.com/display/ESB460/Configure+with+IBM+WebSphere+MQ
on the end I create .bindings file and used. Everything worked fine. So Im able to read messages from Queues that exist in QueueManager.
QUESTION:
Am I need to rebuild .binding file every time when I create new Queue?
is there a way to use/see newly created Queues without rebuild a .binding file?
For connection in \repository\conf\axis2.xml I used
> <parameter name="transport.jms.ConnectionFactoryType" > locked="false">queue</parameter>
> <parameter name="transport.jms.UserName" locked="false">**myname**</parameter>
> <parameter name="transport.jms.Password" locked="false">**mypassword**</parameter>
I see this on http://nandikajayawardana.blogspot.com/search/label/WSo2%20ESB
but maybe I should use this
> <parameter name="transport.jms.ConnectionFactoryType"
> locked="false">**topic**</parameter>
> <parameter name="transport.jms.Destination">ivtT</parameter>
After I tried every single combination. Working solution in my case is :
WMQInitialContextFactory is not recommended... starting from version 8 IBM MQ they using ONLY RefFSContextFactory
so after creating .binding file the repository\conf\axis2.xml should look like
<parameter name="esbMngr" locked="false">
<parameter name="java.naming.factory.initial" locked="false">com.sun.jndi.fscontext.RefFSContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">file:/home/wso2admin/wso2esb-5.0.0/jndi</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">GSTQueueConnectionFactory</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
<parameter name="transport.jms.UserName" locked="false">userName</parameter>
<parameter name="transport.jms.Password" locked="false">userPassword</parameter>
</parameter>
.....
where GSTQueueConnectionFactory is ConectionFactory name that is defined in .binding file
So proxy server looks like :
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse"
name="TMSLeaseMQParser"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="jms">
<target>
<inSequence>
<log level="full">
</log>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.Destination">TMSALease</parameter>
<parameter name="transport.jms.ContentType">
<rules xmlns="">
<jmsProperty>contectType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.ConnectionFactory">esbMngr</parameter> <description/>
</proxy>
So esbMngr is name of section defined in axis2.xml while TMSALease is your message queue that you are reading from IBM MQ
I hope is this is going to save some time someone ... Any feedback is welcome
NOTE: communication can be tricky. Be sure that you check that your userName have access to queue, read more in IBM Technote "2035 MQRC_NOT_AUTHORIZED Connecting to WebSphere MQ from WebSphere Application Server via CLIENT Bindings"
To check MQ OAM permissions us the dspmqaut command, for example:
dspmqaut -m WS02ESBManager -n TMSALease -t queue -p userName
To set MQ OAM permissions us the setmqaut command, for example:
setmqaut -m WS02ESBManager -n TMSALease -t queue -p userName+put
Also sometimes help if you :
Disable Channel authentication records in Communication in Properties of queue manager ...

Scheduled Message Forwarding Processor does not deactivate after X delivery attempts

I'm running WSO2 ESB 4.5.1 with Sun Java SE 1.6.0_33 on Red Hat 2.6.32 using Apache ActiveMQ 5.5.1 as persistent storage to the ESB.
I’m trying to write a flow that:
1. reads address information from XML file
2. save each address in MQ queue
3. have a Message Processor read from MQ and attempt delivery to a JMS Endpoint
4. if the delivery fails the Message Processor is to attempt one more delivery before deactivating itself
When the JMS Endpoint (another ActiveMQ instance running on another server) is up everything works great, but if I stop the ActiveMQ that is acting as the JMS Endpoint the Message Processor does not deactivate as I expect after one retry but continually attempts to resend the same messages from Message Store. What is going wrong?
Here is the flow I have:
Proxy:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="AddressPxy" transports="vfs" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<property name="target.endpoint" value="AddressesEP" scope="default" type="STRING"/>
<log level="full"/>
<iterate expression="//addresses/address">
<target>
<sequence>
<store messageStore="AddressesMS"/>
</sequence>
</target>
</iterate>
</inSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">15</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///home/esb/sent</parameter>
<parameter name="transport.vfs.FileURI">file:///home/esb/addresses.xml</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///home/esb/fail</parameter>
<parameter name="transport.vfs.ContentType">application/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<description></description>
</proxy>
Message Store:
<messageStore name="AddressesMS" 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.JMSSpecVersion">1.1</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
</messageStore>
Message Processor:
<messageProcessor name="AddressesMP" class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor" messageStore="AddressesMS" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="interval">10000</parameter>
<parameter name="max.delivery.attempts">1</parameter>
</messageProcessor>
Endpoint:
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="AddressesEP">
<address uri="jms:/Addresses?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://rhdev001:61616&transport.jms.DestinationType=queue">
</address>
</endpoint>
I see this error message in wso2carbon.log:
TID: [0] [ESB] [2012-11-07 02:58:07,396] ERROR {org.apache.axis2.transport.jms.JMSSender} - Unable to create a JMSMessageSender for : null {org.apache.axis2.transport.jms.JMSSender}
javax.jms.JMSException: Could not connect to broker URL: tcp://rhdev001:61616. Reason: java.net.ConnectException: Connection refused
TID: [0] [ESB] [2012-11-07 02:58:07,398] ERROR {org.apache.synapse.message.processors.forward.BlockingMessageSender} - Error sending Message to url : jms:/Addresses?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://rhdev001:61616&transport.jms.DestinationType=queue {org.apache.synapse.message.processors.forward.BlockingMessageSender}
org.apache.axis2.AxisFault: Unable to create a JMSMessageSender for : null
TID: [0] [ESB] [2012-11-07 02:58:07,399] ERROR {org.apache.synapse.message.processors.forward.ForwardingJob} - Error Forwarding Message {org.apache.synapse.message.processors.forward.ForwardingJob}
java.lang.Exception: Error while Sending Message
Hope someone can help me!
In this version of ESB There is a slight problem with "max.delivery.attempts" parameter in the message processor. But you can make this work by going to source view and changing "max.delivery.attempts" to "max.deliver.attempts".