Getting "Connection closed before sending request out" in WSO2 ESB for newly created API - wso2-esb

I'm getting "Connection closed before sending request out" in my WSO2 ESB API when a request is made to an endpoint. I am not using a proxy server.
Here is the source for the API that I have created:
<api xmlns="http://ws.apache.org/ns/synapse" name="WorkspaceONEUser" context="/workspaceone/user" port="8243">
<resource methods="POST" uri-template="*">
<inSequence>
<log>
<property name="Message Flow" value="POST WorkspaceONEUser Search - IN"/>
</log>
<send>
<endpoint key="workspaceOneUserSearchEndpoint"/>
</send>
</inSequence>
<outSequence>
<property name="Access-Control-Allow-Headers" value="authorization,Access-Control-Allow-Origin,Content-Type,X-Requested-With,Accept,Allow,Access-Control-Allow-Credentials" scope="transport"/>
<property name="Access-Control-Allow-Origin" value="HOST_NAME" scope="transport" type="STRING"/>
<property name="Access-Control-Allow-Credentials" value="true" scope="transport" type="STRING"/>
<log>
<property name="Message Flow" value="POST WorkspaceONEUser - OUT"/>
</log>
<log level="full"/>
<send/>
</outSequence>
<faultSequence>
<log>
<property name="message" value="in fault"/>
<property name="text" value="An unexpected error occured"/>
<property name="message" expression="get-property('ERROR_MESSAGE')"/>
<property name="header" expression="get-property('REQUEST_HOST_HEADER')"/>
</log>
</faultSequence>
</resource>
<resource methods="OPTIONS" url-mapping="/">
<inSequence>
<log>
<property name="Message Flow" value="IN OPTIONS"/>
</log>
<log level="full"/>
<property name="Access-Control-Allow-Headers" value="authorization,Access-Control-Allow-Origin,Content-Type,X-Requested-With,Accept,Allow,Access-Control-Allow-Credentials" scope="transport"/>
<property name="Access-Control-Allow-Origin" value="https://HOST_NAME" scope="transport" type="STRING"/>
<property name="Access-Control-Allow-Credentials" value="true" scope="transport" type="STRING"/>
<respond/>
</inSequence>
</resource>
</api>
In the logs, it appears that the connection is being closed before it is sent out:
TID: [-1234] [] [2019-01-28 13:38:29,283] DEBUG {org.apache.synapse.endpoints.AddressEndpoint} - Sending message through endpoint : workspaceOneUserSearchEndpoint resolving to address = https://TARGET_HOST {org.apache.synapse.endpoints.AddressEndpoint}
TID: [-1234] [] [2019-01-28 13:38:29,283] DEBUG {org.apache.synapse.endpoints.AddressEndpoint} - SOAPAction: null {org.apache.synapse.endpoints.AddressEndpoint}
TID: [-1234] [] [2019-01-28 13:38:29,283] DEBUG {org.apache.synapse.endpoints.AddressEndpoint} - WSA-Action: null {org.apache.synapse.endpoints.AddressEndpoint}
TID: [-1234] [] [2019-01-28 13:38:29,283] DEBUG {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient} - Sending [add = false] [sec = false] [mtom = false] [swa = false] [format = null] [force soap11=false] [force soap12=false] [pox=false] [get=false] [encoding=null] [to=https://TARGET_HOST] {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient}
TID: [-1234] [] [2019-01-28 13:38:29,283] DEBUG {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient} - Message [Original Request Message ID : urn:uuid:09116122-22b4-4acf-be8e-31570623bd39] [New Cloned Request Message ID : urn:uuid:b242c096-4348-4977-8048-d70a5ac8c15b] {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient}
TID: [-1234] [] [2019-01-28 13:38:29,283] DEBUG {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient} - Setting Timeout for endpoint : Endpoint [workspaceOneUserSearchEndpoint], URI : https://TARGET_HOST to static timeout value : 120000 {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient}
TID: [-1234] [] [2019-01-28 13:38:29,284] DEBUG {org.apache.synapse.core.axis2.SynapseCallbackReceiver} - Callback added. Total callbacks waiting for : 2 {org.apache.synapse.core.axis2.SynapseCallbackReceiver}
TID: [-1234] [] [2019-01-28 13:38:29,297] DEBUG {org.apache.axis2.transport.http.ApplicationXMLFormatter} - start writeTo() {org.apache.axis2.transport.http.ApplicationXMLFormatter}
TID: [-1234] [] [2019-01-28 13:38:29,297] DEBUG {org.apache.axis2.transport.http.ApplicationXMLFormatter} - end writeTo() {org.apache.axis2.transport.http.ApplicationXMLFormatter}
TID: [-1234] [] [2019-01-28 13:38:29,297] DEBUG {org.apache.synapse.mediators.builtin.SendMediator} - End : Send mediator {org.apache.synapse.mediators.builtin.SendMediator}
TID: [-1234] [] [2019-01-28 13:38:29,297] DEBUG {org.apache.synapse.mediators.base.SequenceMediator} - End : Sequence <anonymous> {org.apache.synapse.mediators.base.SequenceMediator}
TID: [-1] [] [2019-01-28 13:38:34,781] WARN {org.apache.synapse.transport.passthru.TargetHandler} - Connection closed before sending request out Remote Address : wsoidm01pa.jefferson.edu/147.140.23.161:443 {org.apache.synapse.transport.passthru.TargetHandler}
Does anyone know what might be causing this? I suspect that this indicates a connection between the ESB and a downstream server has closed before the ESB was able to completely write the request out.
However, I'm able to POST to the same endpoint from another API that's almost identical. Is there something that's obviously wrong with my API or endpoint that's causing this mysterious problem?

Try to add this property before your <send> mediator.
<property name="ClientApiNonBlocking"
value="true"
scope="axis2"
action="remove"/>
It will remove your Client Api Non Blocking in your <send> mediator (which is enable by default)

Related

I am working in Generate REST API from SOAP Backend in wso2 APIM but its not working for me

My resource looks like this after creating my APIM using wsdl url
<header description="SOAPAction" name="SOAPAction" scope="transport" value="urn:mediate"/>
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
<property expression="json-eval($.)" name="req.var."/>
<payloadFactory description="transform" media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://ws.apache.org/axis2">
<soapenv:Header/>
<soapenv:Body>
<web:mediate xmlns:web="http://ws.apache.org/axis2"/>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="get-property('req.var.')"/>
</args>
</payloadFactory>
<property description="messageProperty" name="messageType" scope="axis2" type="STRING" value="application/soap+xml"/>
I cannot understand this code...
When I try it gives
{
"Error": {
"Message": "invalid input"
}
}
In log I am getting
[2022-04-21 11:40:07,448] INFO - CarbonAuthenticationUtil 'admin#carbon.super [-1234]' logged in at [2022-04-21 11:40:07,448+0530]
[2022-04-21 11:40:07,760] WARN - SourceHandler STATE_DESCRIPTION = Socket Timeout occurred after accepting the request headers and the request body, INTERNAL_STATE = REQUEST_DONE, DIRECTION = REQUEST, CAUSE_OF_ERROR = Connection between the client and the EI timeouts, HTTP_URL = /SampelProxyAPI/1.0/mediate, HTTP_METHOD = POST, SOCKET_TIMEOUT = 180000, CLIENT_ADDRESS = /0:0:0:0:0:0:0:1:49255, CONNECTION http-incoming-105
[2022-04-21 11:40:08,015] INFO - LogMediator STATUS = Message dispatched to the main sequence. Invalid URL., RESOURCE = /SampelProxyAPI/1.0/mediate, HEALTH CHECK URL = /SampelProxyAPI/1.0/mediate
[2022-04-21 11:48:54,087] WARN - SourceHandler I/O error: Received fatal alert: certificate_unknown

WSO2 EI 6.6.0 with RabbitMQ 3.8.5 - Unable to get exact posted payload in rabbitmq console

I am just trying to post incoming payload to rabbitmq by using messageStore in WSO2 EI 6.6.0.
API-Code:
<api context="/testmqload" name="Test" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<log level="custom">
<property expression="json-eval($)" name="Test"/>
</log>
<property name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="messageType" value="application/json" scope="axis2"/>
<store messageStore="SafaricomRequestStore"/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
MessageStore:
<?xml version="1.0" encoding="UTF-8"?>
<messageStore class="org.apache.synapse.message.store.impl.rabbitmq.RabbitMQStore" name="SafaricomRequestStore" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="store.rabbitmq.host.name">puffin.rmq2.cloudamqp.com</parameter>
<parameter name="store.producer.guaranteed.delivery.enable">false</parameter>
<parameter name="store.rabbitmq.host.port">5672</parameter>
<parameter name="store.rabbitmq.route.key">SafaricomRequestQueue</parameter>
<parameter name="store.rabbitmq.username">username</parameter>
<parameter name="store.rabbitmq.virtual.host">host</parameter>
<parameter name="rabbitmq.connection.ssl.enabled">false</parameter>
<parameter name="store.rabbitmq.exchange.name">amq.direct</parameter>
<parameter name="store.rabbitmq.queue.name">SafaricomRequestQueueTest4</parameter>
<parameter name="store.rabbitmq.password">password</parameter>
</messageStore>
Incoming Request:
{
"result": {
"message": {
"M-PESA_Cash_Out": "10.00",
"M-PESA_Fee": "15.27",
"Transaction_Fee": "0.44",
"acct_no": "4000000009",
"date": "04-JAN-2022",
"power_id": "cab48a3b620e4b3f8d7c2d13a9efced7",
"receiving_mobile": "799999999",
"time": "17:47:29",
"total_amount": "25.71",
"transaction_id": "1002201040000053",
"wallet_bank": "M-PESA"
},
"new_txn_id": 1002201040000053,
"status": "S"
}
}
Message is posted in rabbitMQ like below
when i decoded above screenshot value by using base64 decoder online, getting below values.
If you notice above screenshot, i am geting some other values in addition to posted payload which is marked as yellow above.
By using Inbound endpoint, i tried to fetch message from queue which will print message structure like below in sequence.
{
"text":"base64 encoded value...."
}
may i know why it is having other extra values too in addition with posted payload? or what can i do to fetch only posted payload from queue?
As per tmoasz suggested in comment, modified Code- which are mentioned below.
Modified API :
<?xml version="1.0" encoding="UTF-8"?>
<api context="/rabbitmqtest" name="RabbitMQTestAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<log level="custom">
<property name="RabbitMQTestAPI" value="is called***"/>
<property name="IncomingRequest" expression="json-eval($)"/>
</log>
<property description="Initiate asynchronous mediation flow" name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property description="Generate 202 response from mediation flow" name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
<send description="Publish request payload to AMQP endpoint">
<endpoint key="RabbitMQ-QueueEP"/>
</send>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
Endpoint Code:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="RabbitMQ-QueueEP" xmlns="http://ws.apache.org/ns/synapse">
<address uri="rabbitmq:/RabbitMQTestQueue?rabbitmq.server.host.name=puffin.rmq2.cloudamqp.com&rabbitmq.server.port=5672&rabbitmq.server.user.name=username&rabbitmq.server.password=password&rabbitmq.queue.name=RabbitMQTestQueue&rabbitmq.exchange.name=amq.direct">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
Wire logs:
[2022-01-06 19:01:11,282] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "POST /rabbitmqtest HTTP/1.1[\r][\n]"
[2022-01-06 19:01:11,283] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "Content-Type: application/json[\r][\n]"
[2022-01-06 19:01:11,285] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "User-Agent: PostmanRuntime/7.28.4[\r][\n]"
[2022-01-06 19:01:11,286] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "Accept: */*[\r][\n]"
[2022-01-06 19:01:11,289] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "Cache-Control: no-cache[\r][\n]"
[2022-01-06 19:01:11,290] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "Postman-Token: 75a4502d-7df0-444e-8ba8-39bcd6265204[\r][\n]"
[2022-01-06 19:01:11,290] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "Host: localhost:8280[\r][\n]"
[2022-01-06 19:01:11,291] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2022-01-06 19:01:11,292] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "Connection: keep-alive[\r][\n]"
[2022-01-06 19:01:11,292] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "Content-Length: 25[\r][\n]"
[2022-01-06 19:01:11,293] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "[\r][\n]"
[2022-01-06 19:01:11,300] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "{[\r][\n]"
[2022-01-06 19:01:11,301] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> " "name":"justin"[\r][\n]"
[2022-01-06 19:01:11,302] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-4 >> "}"
[2022-01-06 19:01:11,306] INFO {org.apache.synapse.mediators.builtin.LogMediator} - RabbitMQTestAPI = is called***, IncomingRequest = {
"name":"justin"
}
[2022-01-06 19:01:11,309] INFO {org.apache.axis2.transport.rabbitmq.RabbitMQConnectionFactory} - Initializing channel pool of 20
[2022-01-06 19:01:11,879] ERROR {org.apache.axis2.transport.rabbitmq.RabbitMQConnectionFactory} - [puffin.rmq2.cloudamqp.com_5672_username_passwordI_null_null_null_null_null_null_null_null_null] Error creating connection to RabbitMQ Broker. Reattempting to connect. java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:105)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:101)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:123)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:382)
at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:58)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:103)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:877)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:839)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:661)
at org.apache.axis2.transport.rabbitmq.utils.RabbitMQUtils.createConnection(RabbitMQUtils.java:56)
at org.apache.axis2.transport.rabbitmq.RabbitMQConnectionFactory.createConnection(RabbitMQConnectionFactory.java:159)
at org.apache.axis2.transport.rabbitmq.RMQChannelPool.<init>(RMQChannelPool.java:20)
at org.apache.axis2.transport.rabbitmq.RabbitMQConnectionFactory.initializeConnectionPool(RabbitMQConnectionFactory.java:392)
at org.apache.axis2.transport.rabbitmq.RabbitMQConnectionFactoryManager.getConnectionFactory(RabbitMQConnectionFactoryManager.java:105)
at org.apache.axis2.transport.rabbitmq.RabbitMQSender.getConnectionFactory(RabbitMQSender.java:135)
at org.apache.axis2.transport.rabbitmq.RabbitMQSender.sendMessage(RabbitMQSender.java:81)
at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:297)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:634)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:85)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:571)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:408)
at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:74)
at org.apache.synapse.endpoints.IndirectEndpoint.send(IndirectEndpoint.java:56)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:123)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.rest.Resource.process(Resource.java:331)
at org.apache.synapse.rest.API.process(API.java:441)
at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:135)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:113)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:71)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:327)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:98)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:368)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:427)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:182)
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: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method: #method<connection.close>(reply-code=530, reply-text=NOT_ALLOWED - access to vhost '/' refused for user 'username', class-id=10, method-id=40)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:32)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:366)
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:229)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117)
... 42 more
If you want to send, just JSON message as payload to RabbitMQ, don't use message store. Message stores, are storing all synapse message context with payload for later processing - that is their purpose. So that is why you see in decoded RabbitMQ Payload not only the message, but also additional properties.
For sending JSON to RabbitMQ you can use just <send/> to a proper endpoint.
Look as this documentation sample.
I have also have made some sequance template for more easy use of sending messages to rabitmq, so next you can may look at this helpful post, and adapt to your own needs.
I have resolved above issue by making endpoint call with the use of send mediator as #tmoasz suggested instead of message store.
API Code:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/rabbitmqtest" name="RabbitMQTestAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<log level="custom">
<property name="RabbitMQTestAPI" value="is called***"/>
<property name="IncomingRequest" expression="json-eval($)"/>
</log>
<property description="Initiate asynchronous mediation flow" name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property description="Generate 202 response from mediation flow" name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
<send description="Publish request payload to AMQP endpoint">
<endpoint key="RabbitMQ-QueueEP"/>
</send>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
RabbitMQ-QueueEP :
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="RabbitMQ-QueueEP" xmlns="http://ws.apache.org/ns/synapse">
<address uri="rabbitmq:/AMQPConnectionFactory?rabbitmq.server.host.name=puffin.rmq2.cloudamqp.com&rabbitmq.server.port=5672&rabbitmq.server.user.name=username&rabbitmq.server.password=password&rabbitmq.queue.name=RabbitMQTestQueue&rabbitmq.queue.routing.key=RabbitMQTestQueue&rabbitmq.server.virtual.host=hostname&rabbitmq.exchange.name=amq.direct">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
API Hit:
RabbitMQ Console:

dblookup mediator not executed if it is placed after an iterate mediator

Does anyone know why a dblookup mediator is not executed if it is placed after an iterate mediator and both of these mediators are enclosed within a filter mediator? See my code snippet and corresponding log below. Thank you in advance.
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="DownloadSeq" onError="AppDefaultFailSeq"
trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<dblookup description="DOWNLOAD FILES">
<connection>
<pool>
<dsName>jdbc/dsName</dsName>
</pool>
</connection>
<statement>
<sql><![CDATA[some sql query]]></sql>
<result column="id" name="fileId"/>
<result column="file_name_pattern" name="fileNamePattern"/>
<result column="uri" name="fileSource"/>
<result column="file_dest" name="fileDest"/>
</statement>
</dblookup>
<!-- CHECK TO SEE IF A RECORD IS RETURNED. EXIT IF NO RECORD RETURNED -->
<filter xpath="boolean(get-property('fileId'))">
<then>
<fileconnector.search>
<source>{$ctx:fileSource}</source>
<filePattern>{$ctx:fileNamePattern}</filePattern>
<recursiveSearch>False</recursiveSearch>
</fileconnector.search>
<log level="full"/>
<property name="sequence" scope="default" type="STRING" value="after-smooks"/>
<iterate expression="//ns:result/ns:file" xmlns:ns="http://org.wso2.esbconnectors.FileConnector">
<target>
<sequence>
<log level="full"/>
<property expression="//ns:file" name="fileName"
scope="default" type="STRING"/>
<!-- DOWNLOAD THE FILE -->
<fileconnector.move>
<source>{$ctx:fileSource}</source>
<destination>{$ctx:fileDest}</destination>
</fileconnector.move>
</sequence>
</target>
</iterate>
<!-- UPDATE STATUS AS 'P' -->
<dblookup description="Update status to P">
<connection>
<pool>
<dsName>jdbc/dsName</dsName>
</pool>
</connection>
<statement>
<sql><![CDATA[some SQL statement]]></sql>
<parameter expression="get-property('fileId')" type="INTEGER"/>
<parameter type="CHAR" value="P"/>
</statement>
</dblookup>
<drop/>
</then>
<else>
<drop/>
</else>
</filter>
</sequence>
From the log file:
TID: [-1234] [] [2016-10-03 10:48:00,848] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} - Start : Class mediator {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:48:00,849] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} - invoking : class org.wso2.carbon.connector.FileMove.mediate() {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:48:01,396] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} - End : Class mediator {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:48:01,397] DEBUG {org.apache.synapse.mediators.base.SequenceMediator} - End : Sequence <anonymous> {org.apache.synapse.mediators.base.SequenceMediator}
However, if I placed the dblookup mediator within the iterator mediator, it works as expected. see corresponding logs below.
TID: [-1234] [] [2016-10-03 10:33:01,037] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} - Start : Class mediator {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:33:01,038] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} - invoking : class org.wso2.carbon.connector.FileMove.mediate() {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:33:01,525] DEBUG {org.apache.synapse.mediators.ext.ClassMediator} - End : Class mediator {org.apache.synapse.mediators.ext.ClassMediator}
TID: [-1234] [] [2016-10-03 10:33:01,526] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} - Start : DBLookup mediator {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,526] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} - Getting a connection from DataSource jdbc/dsName and preparing statement : SELECT update_file_status(?,?) {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,526] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} - Setting as parameter : 1 value : 16 as JDBC Type : 4(see java.sql.Types for valid types) {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,526] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} - Setting as parameter : 2 value : P as JDBC Type : 1(see java.sql.Types for valid types) {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,526] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} - Successfully prepared statement : SELECT update_file_status(?,?) against DataSource : jdbc/dsName {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,527] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} - Processing the first row returned : SELECT update_file_status(?,?) {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,527] DEBUG {org.apache.synapse.mediators.db.DBLookupMediator} - End : DBLookup mediator {org.apache.synapse.mediators.db.DBLookupMediator}
TID: [-1234] [] [2016-10-03 10:33:01,528] DEBUG {org.apache.synapse.mediators.base.SequenceMediator} - End : Sequence <anonymous> {org.apache.synapse.mediators.base.SequenceMediator}
In iterate mediator, use attribute continueParent="true"

WSO2ESB - API Logging everything twice

I've been working on an API to test a platform I've been involved with on my project at work and, after coming back from Christmas break, I notice that it's suddenly logging everything twice and I'm not sure why - if anyone could suggest a reason for this and how to stop it from doing it, that'd be much appreciated. Examples below.
The code:
<iterate expression="//tests">
<target>
<sequence>
<switch source="//tests/type">
<case regex="GW">
<log level="custom">
<property name="TYPE" value="GW"/>
</log>
<send>
<endpoint>
<http trace="disable" uri-template="http://localhost:8280/testsuite/node/gw"/>
</endpoint>
</send>
</case>
<case regex="ESB">
<log level="custom">
<property name="TYPE" value="ESB"/>
</log>
<send>
<endpoint>
<http trace="disable" uri-template="http://localhost:8280/testsuite/node/esb"/>
</endpoint>
</send>
</case>
<case regex="MB">
<log level="custom">
<property name="TYPE" value="MB"/>
</log>
<send>
<endpoint>
<http trace="disable" uri-template="http://localhost:8280/testsuite/node/mb"/>
</endpoint>
</send>
</case>
<default>
<log level="custom">
<property name="OOPS" value="NODE DOESN'T EXIST"/>
</log>
</default>
</switch>
</sequence>
</target>
</iterate>
The logs:
[2016-01-13 09:29:17,331] INFO - STRT = STARTING TESTSUITE IN SEQUENCE {org.apache.synapse.mediators.builtin.LogMediator}
[2016-01-13 09:29:17,332] INFO - STRT = STARTING TESTSUITE IN SEQUENCE {API_LOGGER.JLRWSO2TestSuiteAPI}
[2016-01-13 09:29:17,334] INFO - TYPE = ESB {org.apache.synapse.mediators.builtin.LogMediator}
[2016-01-13 09:29:17,340] INFO - STRT = STARTING ESB IN SEQUENCE {org.apache.synapse.mediators.builtin.LogMediator}
[2016-01-13 09:29:17,341] INFO - STRT = STARTING ESB IN SEQUENCE {API_LOGGER.testesb}
[2016-01-13 09:29:17,345] INFO - STRT = STARTING TESTSUITE OUT SEQUENCE {org.apache.synapse.mediators.builtin.LogMediator}
[2016-01-13 09:29:17,346] INFO - STRT = STARTING TESTSUITE OUT SEQUENCE {API_LOGGER.JLRWSO2TestSuiteAPI}
[2016-01-13 09:29:17,346] INFO - To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:aafbecb4-c2fd-4d04-a64a-3e4bf1a63e50, Direction: response, Envelope: OK1 {org.apache.synapse.mediators.builtin.LogMediator}
[2016-01-13 09:29:17,347] INFO - ENDO = ENDING TESTSUITE OUT SEQUENCE {org.apache.synapse.mediators.builtin.LogMediator}
[2016-01-13 09:29:17,347] INFO - ENDO = ENDING TESTSUITE OUT SEQUENCE {API_LOGGER.JLRWSO2TestSuiteAPI}
From what I can tell, with my limited knowledge and experience of API development, the logs are coming from two different sources. I don't know how to stop one of them so it just logs once, and I wouldn't know which to stop even if I knew how.
Any help would be much appreciated.
Edit repository/conf/log4j.properties and add those lines at the end :
log4j.category.org.apache.synapse.mediators.builtin.LogMediator=OFF
log4j.additivity.org.apache.synapse.mediators.builtin.LogMediator=false
You must restart the ESB
Resolved the issue by switching the API_LOGGER.testapi to False from the Carbon GUI console.

WSO2 ESB : Aggregate node droppping message after aggregation

I am implementing the Fan out -- Fan in splitter EIP inside a proxy , whereby :
|-----> shoe store-(1-M)-------------
productSearchRq -- |-->Rs
|-----> ack clothes store-(0-1)------
Shoe store = Data service and Clothes store = Axis 2 service .
So in short I implement the pattern above ; I clone the request , send it , get responses , format them using payloadFactory:
<productDetails>
<productID>$1</productID>
<productName>$2</productName>
<productSize>$3</productSize>
<productColour>$4</productColour>
<productType>$5</productType>
<sourceID>$6</sourceID>
</productDetails>
on both responses ( and iterate [//productDetails , iterate id = iT] on shoe products since it's one to many). Then in the following response handler , I try to aggregate all these productDetails.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="productSearchHandler">
<log level="custom">
<property name="pocSearchRsHandlerSeq reached" value="++++++++++++++=========Aggregating now========+++++++++++++++++=="></property>
</log>
<aggregate id="iT">
<completeCondition>
<messageCount min="-1" max="-1"></messageCount>
</completeCondition>
<onComplete xmlns:ns="http://org.apache.synapse/xsd" expression="//productDetails">
<log level="custom" separator=",">
<property name="::::" value="======================= Formatting the Aggregated Responses. ==============="></property>
</log>
<log level="full"></log>
</onComplete>
</aggregate>
<aggregate>
<completeCondition>
<messageCount min="-1" max="-1"></messageCount>
</completeCondition>
<onComplete xmlns:ns="http://org.apache.synapse/xsd" expression="//productDetails">
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://za.co.pepkor/product_service/">
<soapenv:Body>
<prod:productSearchResp> $1 </prod:productSearchResp>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg expression="//productDetails" evaluator="xml"></arg>
</args>
</payloadFactory>
<switch source="get-property('CallType')">
<case regex="SOAP">
<send></send>
</case>
<case regex="REST">
<property name="messageType" value="application/json" scope="axis2" type="STRING"></property>
<send></send>
</case>
<default></default>
</switch>
</onComplete>
</aggregate>
</sequence>
The filter's there to cater for the API implementation of this proxy. And I do need 2 aggregators because I use a clone AND iterator mediator.
So I am wondering why before my second aggregator , the message is being "reset" to an empty soap message and therefore the 2nd agg fails to find //productDetails. See following log entries :
After 1st agg which aggregates shoe prods:
TID: [0] [ESB] [2015-02-27 09:46:24,520] DEBUG {org.apache.synapse.mediators.eip.aggregator.AggregateMediator} - Merging message : <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><productDetails><productID>1124596</productID><productName>REEBOK_SNEAKERS</productName><productSize>7</productSize><productColour>BROWN</productColour><productType>SHOES</productType><sourceID>SHC</sourceID></productDetails></soapenv:Body></soapenv:Envelope> using XPath : //productDetails {org.apache.synapse.mediators.eip.aggregator.AggregateMediator}
TID: [0] [ESB] [2015-02-27 09:46:24,522] DEBUG {org.apache.synapse.mediators.eip.aggregator.AggregateMediator} - Merged result : <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><productDetails><productID>1452168</productID><productName>PUMPS</productName><productSize>7</productSize><productColour>ORANGE</productColour><productType>SHOE</productType><sourceID>SHC</sourceID></productDetails><productDetails><productID>1124596</productID><productName>REEBOK_SNEAKERS</productName><productSize>7</productSize><productColour>BROWN</productColour><productType>SHOES</productType><sourceID>SHC</sourceID></productDetails></soapenv:Body></soapenv:Envelope> {org.apache.synapse.mediators.eip.aggregator.AggregateMediator}
TID: [0] [ESB] [2015-02-27 09:46:24,523] DEBUG {org.apache.synapse.mediators.eip.aggregator.AggregateMediator} - Merging message : <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><productDetails><productID>1123456</productID><productName>NIKE_SHIRTS</productName><productSize>7</productSize><productColour>RED</productColour><productType>SHIRT</productType><sourceID>SHC</sourceID></productDetails></soapenv:Body></soapenv:Envelope> using XPath : //productDetails {org.apache.synapse.mediators.eip.aggregator.AggregateMediator}
TID: [0] [ESB] [2015-02-27 09:46:24,525] DEBUG {org.apache.synapse.mediators.eip.aggregator.AggregateMediator} - Merged result : <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><productDetails><productID>1452168</productID><productName>PUMPS</productName><productSize>7</productSize><productColour>ORANGE</productColour><productType>SHOE</productType><sourceID>SHC</sourceID></productDetails><productDetails><productID>1124596</productID><productName>REEBOK_SNEAKERS</productName><productSize>7</productSize><productColour>BROWN</productColour><productType>SHOES</productType><sourceID>SHC</sourceID></productDetails><productDetails><productID>1123456</productID><productName>NIKE_SHIRTS</productName><productSize>7</productSize><productColour>RED</productColour><productType>SHIRT</productType><sourceID>SHC</sourceID></productDetails></soapenv:Body></soapenv:Envelope> {org.apache.synapse.mediators.eip.aggregator.AggregateMediator}
Then as we are going into 2nd agg :
TID: [0] [ESB] [2015-02-27 09:46:24,545] DEBUG {org.apache.synapse.mediators.eip.aggregator.AggregateMediator} - Generating Aggregated message from : <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><productDetails><noItemFound>No item in Ackerman's</noItemFound></productDetails></soapenv:Body></soapenv:Envelope> {org.apache.synapse.mediators.eip.aggregator.AggregateMediator}
TID: [0] [ESB] [2015-02-27 09:46:24,547] DEBUG {org.apache.synapse.mediators.eip.aggregator.AggregateMediator} - Merging message : <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body></soapenv:Body></soapenv:Envelope> using XPath : //productDetails {org.apache.synapse.mediators.eip.aggregator.AggregateMediator}
TID: [0] [ESB] [2015-02-27 09:46:24,550] ERROR {org.apache.synapse.mediators.eip.aggregator.AggregateMediator} - Error evaluating expression: //productDetails {org.apache.synapse.mediators.eip.aggregator.AggregateMediator}
What I want is to merge
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><productDetails><productID>1452168</productID><productName>PUMPS</productName><productSize>7</productSize><productColour>ORANGE</productColour><productType>SHOE</productType><sourceID>SHC</sourceID></productDetails><productDetails><productID>1124596</productID><productName>REEBOK_SNEAKERS</productName><productSize>7</productSize><productColour>BROWN</productColour><productType>SHOES</productType><sourceID>SHC</sourceID></productDetails><productDetails><productID>1123456</productID><productName>NIKE_SHIRTS</productName><productSize>7</productSize><productColour>RED</productColour><productType>SHIRT</productType><sourceID>SHC</sourceID></productDetails></soapenv:Body></soapenv:Envelope>
with
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><productDetails><noItemFound>No item in Ackerman's</noItemFound></productDetails></soapenv:Body></soapenv:Envelope>
Hi if you are using clone mediator with one aggregate mediator you can aggregate the response from two different services. check this tutorial how that works
http://architects.dzone.com/articles/wso2-esb-cloning-and