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>
Related
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>
When I try to create an LDAP Base user store in WSO2 IS 5.3.0 I always get the following error:
TID: [-1234] [] [2017-04-03 11:40:49,521] ERROR {org.wso2.carbon.identity.user.store.configuration.UserStoreConfigAdminService} - Error occurred during the transformation process of C:\WSO2IS~1.0\bin\..\repository\deployment\server\userstores\myUserStore.xml
org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException: Error occurred during the transformation process of C:\WSO2IS~1.0\bin\..\repository\deployment\server\userstores\myUserSotre.xml
I have tried previous version and it fails till 5.0.0, in which I succeed in create the user store. User store config in WSO2 ESB seems to works the same way that WSO2 IS user store, so, I configured the user store in WSO2 ESB, and copy the myUserSotre.xml generated by WSO2 ESB just in the same path where IS failed to find the file.
That worked, and result in WSO2 IS recognizing the User Store. I can see the users from the user store in WSO2 IS user store. However, if I try update the "forced" user store, it keeps throwing the error.
I am using windows 7 and jdk 8.
This is the xml from ESB and IS 5.0.0 that works if I paste it in IS 5.3
<?xml version="1.0" encoding="UTF-8"?>
<UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager">
<Property name="ConnectionName">cn=Manager,dc=company,dc=com</Property>
<Property name="ConnectionURL">ldap://IP:HOST</Property>
<Property name="ConnectionPassword">password</Property>
<Property name="UserSearchBase">ou=People,dc=company,dc=com</Property>
<Property name="Disabled">false</Property>
<Property name="UserNameListFilter">(objectClass=person)</Property>
<Property name="UserNameAttribute">uid</Property>
<Property name="UserNameSearchFilter">(&(objectClass=person)(uid=?))</Property>
<Property name="ReadOnly">true</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="SCIMEnabled">false</Property>
<Property name="ReadGroups">false</Property>
<Property name="GroupSearchBase">ou=system</Property>
<Property name="GroupNameListFilter">(objectClass=groupOfNames)</Property>
<Property name="GroupNameSearchFilter">(&(objectClass=groupOfNames)(cn=?))</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="MembershipAttribute">member</Property>
<Property name="MemberOfAttribute"/>
<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
<Property name="ReplaceEscapeCharactersAtUserLogin">true</Property>
<Property name="DomainName">ldap</Property>
<Property name="Description"/>
</UserStoreManager>
Is there any issue about this? Is there extra configuration needed?
This happens in Windows because of the file path encoding. Currently this is not fixed from WSO2 side. As a work around, you can rename WSO2IS~1.0 folder not contain the '~' character. eg. rename it with WSO2IS and try.
The solution is simple. Set environment variable CARBON_HOME to the path of your wso2 IS folder.
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"
I am using WSO2 ESB 4.8.1. When i use log mediator, i want it to also log the proxy service name in which log mediator is being used. Is there any property defined in wso2 that i can use?
Problem:
In the following log mediator I am using "Server_IP" and "Server_HOST" property to pick up the Server IP and Server Host name. So is there any property from which i can pick up the service name.
Log Mediaator:
<log level="full" separator="LogMediator" description="LoggerTemplate">
<property name="ServerIP" expression="get-property('SERVER_IP')"/>
<property name="ServerHost" expression="get-property('SERVER_HOST')"/>
</log>
Yes. Use the $ctx:proxy.name expression for your property mediator:
<log level="custom">
<property name="proxyName" expression="$ctx:proxy.name"/>
</log>
Output:
[2015-02-06 06:24:07,161] INFO - LogMediator proxyName = vfsTest
I am using wso2 esb 4.8.1,
I wish to handle warning of endpoints.I am trying to hit CXF services in tomcat server.
If I test with wrong action (Operation/method)name or service name in tomcat.
I am getting this message in SOAP.
<html>
<body>No service was found.</body>
</html>
Where as in my wso2esb not getting logged any error and that particular endpoint failing showing this message.
[2014-11-24 16:57:57,931] WARN - LoadbalanceEndpoint Endpoint [ServiceLEP] Detect a Failure in a child endpoint : Endpoint [EP3]
Since I don't know the CXF I wish to handle this in wso2esb How would I handle this message and send proper error response to client.
Is any one able to help me.
Thanks in advance.
If you are using a mediator, the response will be available in the inSequence. You can log that response with code such as this after your mediator:
<enrich>
<source type="body"/>
<target type="property" action="child" property="response_body"/>
</enrich>
<log level="custom">
<property name="The Response" expression="get-property('response_body')"/>
</log>
Please advise if that works in your scenario.
If your endpoint is suspended, then WSO2 by default initiate fault sequence, you can define your custom message in the fault sequence and then send it back to the client as you want. You can get ERROR_CODE and ERROR_MESSAGE property from WSO2 in Log or Switch mediator where u can check it. In log u can do it as following:
<log level="full" separator="**********Fault Sequence File Processor***********">
<property name="ErrorCode" expression="get-property('ERROR_CODE')"></property>
<property name="ErrorMessage" expression="get-property('ERROR_MESSAGE')"></property>
<property name="ErrorDetail" expression="get-property('ERROR_DETAIL')"></property>
<property name="ErrrorException" expression="get-property('ERROR_EXCEPTION')"></property>
</log>
You can make a check on ERROR_CODE property or ERROR_MESSAGE property in Switch mediator and then with the help of Payload mediator u can define your custom error message.