How to increase the server startup timeout in WSO2 Integration Studio? - wso2

I want to make an oracle database connection by opening a dataservice project with WSO2 Integration studio application. I can connect to the Oracle database. But when I run the dataservice project, the WSO2 Integration Studio application goes into time out and asks us to increase the time out time. How and where should we increase this time?
Integration Studio Dataservice project Xml :
<data transports="http https" serviceGroup="" serviceNamespace="" name="demoDataService">
<description />
<resource method="GET" path="GetGenders">
<call-query href="GetGenders" />
</resource>
<config id="OracleDataSourceIdenfierName" enableOData="true">
<property name="driverClassName">oracle.jdbc.driver.OracleDriver</property>
<property name="url">jdbc:oracle:thin:#host:port/schema_name</property>
<property name="username">username</property>
<property name="password">password</property>
</config>
<query id="GetGenders" useConfig="OracleDataSourceIdenfierName">
<sql>SELECT column1,column2 FROM schema_name.table_name</sql>
<result outputType="json">{
"Genders": {
"Gender": [
{
"column1": "$column1",
"column2": "$column2"
}
]
}
}</result>
<properties>
<property name="fetchDirection">forward</property>
</properties>
</query>
</data>
WSO2 Integration Studio Timeout Error:

Go to Window -> Show View -> Other Then search for Servers. Select Servers and click on Open.
Then Double Click on the "Micro Integrator Server 4.1" Then look for the timeout settings.

Related

ESB WSO2 | Trying to send an email through email connector and getting "org.wso2.carbon.connector.email.send cannot be found" error

I'm trying to send an email using email connector from esb wso2 but I'm getting this error:
Invoking Target EIP Sequence org.wso2.carbon.connector.email.send paramNames : [from, to, subject, content, contentType]
[2022-07-22 10:52:14,113] ERROR {org.apache.synapse.mediators.template.InvokeMediator} - Sequence template org.wso2.carbon.connector.email.send cannot be found
[2022-07-22 10:52:14,121] DEBUG {org.apache.synapse.debug.SynapseDebugManager} - Mediation flow terminated for id urn:uuid:3f3f9864-bbc1-4e95-a4bf-1574196dfb8c
[2022-07-22 10:52:14,121] WARN {org.apache.synapse.core.axis2.SynapseMessageReceiver} - Executing fault handler due to exception encountered
[2022-07-22 10:52:14,121] WARN {org.apache.synapse.FaultHandler} - ERROR_CODE : 0
[2022-07-22 10:52:14,121] WARN {org.apache.synapse.FaultHandler} - ERROR_MESSAGE : Sequence template org.wso2.carbon.connector.email.send cannot be found
[2022-07-22 10:52:14,122] WARN {org.apache.synapse.FaultHandler} - ERROR_DETAIL : org.apache.synapse.SynapseException: Sequence template org.wso2.carbon.connector.email.send cannot be found
This is my api which I use:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/api/send/email" name="api.send.email" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<property expression="json-eval($.from)" name="from" scope="default" type="STRING"/>
<property expression="json-eval($.to)" name="to" scope="default" type="STRING"/>
<property expression="json-eval($.subject)" name="subject" scope="default" type="STRING"/>
<property expression="json-eval($.content)" name="content" scope="default" type="STRING"/>
<property expression="json-eval($.contentType)" name="contentType" scope="default" type="STRING"/>
<log level="custom">
<property expression="$ctx:from" name="Log_from:"/>
<property expression="$ctx:to" name="Log_to:"/>
<property expression="$ctx:subject" name="Log_subject:"/>
<property expression="$ctx:content" name="Log_content:"/>
<property expression="$ctx:contentType" name="Log_contentType:"/>
</log>
<email.send configKey="TEST_SMTP_CONNECTION">
<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>
</email.send>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
I think the problem is based on the fact that I don't think I added the connector on my project in the correct way.
So, first of all I added a connector on my main project (where I have APIs, endpoints etc) - Right Click - Add or Remove Connector/Module - then I added the email connector)
Then I created a new Connector Exporter on my project (Right Click on an empty space on my Project Explorer - I named the exporter 'test' - and I think here is the problem:
What Group ID, Parent Group ID and Parent Artifact ID I should choose? (same question when I'm making Composite Application for connector)
LATER EDIT*:
When I'm deploying de car. app for the email connector I'm getting these errors:
Error in instantiating class : org.wso2.carbon.connector.operations.list.EmailGetAttachment java.lang.NoClassDefFoundError: org/wso2/carbon/connector/core/exception/ContentBuilderException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.newInstance(Class.java:412)
Unable to update status for : {org.wso2.carbon.connector}email :: Template configuration : null cannot be builtfor Synapse Library artifact : getEmailAttachment org.apache.synapse.deployers.SynapseArtifactDeploymentException: Template configuration : null cannot be builtfor Synapse Library artifact : getEmailAttachment
To answer your questions, if you have a Maven MultiModule Project you can get the details of the parent project from the pom.xml of the parent project.(This is the root pom.xml typically)
The easiest way to resolve your problem is to create your project from an existing template which will make sure projects are created correctly. Inorder to do that, follow the steps below.
Open Integration Studio and Go to Help -> Getting Started.
Then select the Email Service sample project, give it a name and create the project.
Now you should have a full working project with a Connector Exported.
In the future for creating new projects, you can refer to this document.

Tracing messages through logs in WSO2 ESB 4.8.1

I need to get a unique ID to trace messages through logs.
I am using WSO2 ESB 4.8.1.
I have found an article related to WSO2 ESB 5.0.0. http://nuwanzone.blogspot.it/2016/12/wso2-esb-tracing-messages-through-logs.html .
It describes how setting a unique ID per each message using the MessageContext object so that I can access it from anywhere within the message flow.
Is it possible implement a similar solution in WSO2 ESB 4.8.1 too? (porting that) solution in WSO2 ESB 4.8.1?
Do you know different solutions?
You can save the MessageID in a property at startup, and add it to your log mediators. Example:
<property description="SetMessageUUID" expression="fn:substring-after(get-property('MessageID'), 'urn:uuid:')" name="MessageUUID" scope="default" type ="STRING"/>
<log>
<property name="Step" expression="Request service A"/>
<property name="ID" expression="get-property('MessageUUID')"/>
</log>
<call>
.....
</call>
<log>
<property name="Step" expression="Response service A"/>
<property name="ID" expression="get-property('MessageUUID')"/>
</log>

Error with WSO2 ESB when trying to connect to Jira and ElasticSearch

I have and scenario where I want to extract dynamically Issues from Jira in order to save them on ElasticSearch. I use a custom Proxy Service that connect with Jira (via Jira connector), get a project (first I want to save the project's information) and pass this information to Elastic. Following is the in Sequence of the proxy service:
<?xml version="1.0" encoding="UTF-8"?>
<inSequence xmlns="http://ws.apache.org/ns/synapse">
<property expression="json-eval($.username)" name="username"/>
<property expression="json-eval($.password)" name="password"/>
<property expression="json-eval($.uri)" name="uri"/>
<property expression="json-eval($.id)" name="id"/>
<property expression="json-eval($.uriEl)" name="uriEl"/>
<property expression="json-eval($.indexName)" name="indexName"/>
<property expression="json-eval($.type)" name="type"/>
<property expression="json-eval($.message)" name="message"/>
<jira.init>
<username>{$ctx:username}</username>
<password>{$ctx:password}</password>
<uri>{$ctx:uri}</uri>
</jira.init>
<jira.getProject>
<projectIdOrKey>{$ctx:id}</projectIdOrKey>
</jira.getProject>
<property expression="json-eval($.project)" name="project"
scope="default" type="STRING"/>
<elasticsearch.init>
<apiUrl>{$ctx:uriEl}</apiUrl>
</elasticsearch.init>
<elasticsearch.createDocumentWithIndex>
<indexName>{$ctx:indexName}</indexName>
<type>{$ctx:type}</type>
<message>{$ctx:message}</message>
<body>{$ctx:project}</body>
</elasticsearch.createDocumentWithIndex>
<respond/>
</inSequence>
And here is the sample request:
{
"username":"MyName",
"password":"AnStrongPassword",
"uri":"JiraURL",
"id":"MyProject",
"uriEl":"http://localhost:9200",
"indexName":"jira",
"type":"project",
"message":"Testing"
}
The other parameters (Endpoint, out Sequence and Fault Sequence) are by default.
The problem is that when I try to send this request via 'Try the Test service' option on WSO2 ESB, i get the following error:
Error connecting to the Tryit ajax proxy
I have tested the same code but only using the Jira connection (without get a project or connect to Elastic), and the same error occurs.
Looking to this error, I suppose that the problem is before to read the JSON request, but I don't know if it is related to the endpoint (I think that it is not necessary an endpoint for this scenario).
Thanks in advance.
This problem is totally independent of the jira connector etc. Problem is with the "try it" tool. This tool is not that much recommended for testing purposes. Instead of that, try invoking the proxy service via soap ui.
If you share a screenshot when the try it error occurs, I'll be able to comment on that as well.
After a few days I have found another solution to my problem without using proxy services. To connect ESB with Jira, I created this API on ESB:
<api xmlns="http://ws.apache.org/ns/synapse" name="transport_service" context="/transport_service">
<resource methods="GET">
<inSequence>
<jira.init>
<uri>MyURL</uri>
<username>MyUser</username>
<password>3MyPass</password>
</jira.init>
<jira.searchJira>
<query>project=MyProject</query>
<maxResults>50000</maxResults>
<fields>MyField1,MyField2,etc</fields>
</jira.searchJira>
<respond/>
</inSequence>
<outSequence>
<log level="full"/>
<property name="messageType" value="application/xml" scope="axis2"/>
<send/>
</outSequence>
</resource>
</api>
The command to call this API is simple:
curl -v -X GET http://localhost:8280/transport_service > jira-db.json
Finally, if you want to insert this json on elastic, you can follow the typical PUT via curl:
curl -XPUT 'http://localhost:9200/jira/jira/1' -d #jira-db.json
Additionally, you can write both commands on a daily bash script (using your scheduled task list), getting the same result that scheduling your proxy service on WSO2ESB:
#!/bin/bash
curl -v -X GET http://localhost:8280/transport_service > jira-db.json
curl -XPUT 'http://localhost:9200/jira-dev/jira/1' -d #jira-db.json
echo "Daily load completed"

WSO2 task to run exactly once at startup

I need a task to be run exactly once at the wso2 startup. How do we ensure this.
The following did not work in the scheduled task
<trigger once="true"/>
Try with
<trigger count="1" interval="1"/>
I am using the ESB 4.8.1. For me both configurations are worked fine. Followings are the sample schedule tasks which I have tested in each case.
1.Configuration 1 -<trigger once="true"/>
<?xml version="1.0" encoding="UTF-8"?>
<task xmlns="http://ws.apache.org/ns/synapse" name="MyTask" class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz">
<trigger once="true"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
<name xmlns="">The message will be displayed once</name>
</property>
</task>
2.Configuration -<trigger count="1" interval="1"/>
<?xml version="1.0" encoding="UTF-8"?>
<task xmlns="http://ws.apache.org/ns/synapse" name="MyTask" class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz">
<trigger count="1" interval="1"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
<name xmlns="">The message will be displayed once</name>
</property>
</task>
However, in the ESB documentation recommended to use <trigger once="true"/> to execute tasks only once after the esb starts.
I also had the same problem (using ESB4.9). After trying lots of options I found a working config to be:
<trigger once="true" count="1" interval="1"/>
There seems to be a bug that is still present in the latest ESB (Integrator v. 6.4.0).
The only way a trigger will launch on startup and/or deployment of CAR archive, is if you set the interval to any number higher than 1000. I set it to 1001 and it ran straight away both on deployment as well as on restart. Example config below:
<?xml version="1.0" encoding="UTF-8"?>
<task class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz" name="TSK_Logoff" xmlns="http://ws.apache.org/ns/synapse">
<trigger interval="1001" count="1" />
<property name="sequenceName" value="SEQ_Logoff" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="injectTo" value="sequence" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="message" xmlns:task="http://www.wso2.org/products/wso2commons/tasks">
<logoff/>
</property>
Just for the record, the version that I was using was 4.8.1. I did not solve this issue, instead worked-around it and moved the feature that we had to do an exactly once. I moved that from the WSO2 startup to our web layer and thus saved ourselves the trouble of fighting with various WSO2 version upgrades in the future.
I know that this issue happened in early 2016 and it looks odd for me to answer it in March 2019. But this issue seems to be happening on the newer version of WSO2 as well and fellow architects have been referring/commenting to this post even in Jan 2019. Therefore, it would be appropriate for me to comment on what I finally did.

How to call sequence in Task Scheduler in wso2 esb

I want to run a proxy(pass through) or a sequence(pass through type) repeatatively after every 60 seconds so i started with Task Scheduler but i am not able to figure out how can i achieve my requirement using Task Scheduler. I want to execute my proxy or sequence after every 60 seconds.Like in wso2 BPS we can achieve this thing using loops, Likewise is there anything in esb that can schedule run a proxy or sequence after certain interval of time? Looking forward to your answers.
Thanks in advance.
IS it possible to achieve above requirement in wso2 esb. Please Help.
You can use the task to run a proxy service which is configured in your ESB. You need to configure the task as below.
Here is a sample configuration to access the SimpleStockQuoteService sample service which comes with the ESB. You can replace the value of the "to" property to match your proxy endpoint and set the desired message.
<task class="org.apache.synapse.startup.tasks.MessageInjector" name="CheckPrice">
<property name="to" value="http://localhost:9000/services/SimpleStockQuoteService"/>
<property name="soapAction" value="urn:getQuote"/>
<property name="message">
<m0:getQuote xmlns:m0="http://services.samples">
<m0:request>
<m0:symbol>IBM</m0:symbol>
</m0:request>
</m0:getQuote>
</property>
<trigger interval="5"/>
</task>
Form WSO2 ESB version 4.7.0 new properties are added to task component. Using those we can call a proxy service or sequence from our task scheduler. Below are my sample code for calling a proxy service
<task name="DBPOller"
class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz">
<trigger count="2" interval="5"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="soapAction"
value="urn:getRequestForm"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
<p:getRequestForm xmlns:p="http://ws.wso2.org/dataservice"><!--Exactly 1 occurrence--><p:isRead>n</p:isRead>
</p:getRequestForm>
</property>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="injectTo"
value="proxy"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="proxyName"
value="DBPollerService"/>
</task>