Created
December 2, 2013 10:41
-
-
Save anonymous/7747764 to your computer and use it in GitHub Desktop.
My Postgresql Salesdetails_DataService, and Java file , i export the jar file in /home/youtylity5/Downloads/LatestVersion/wso2dss-3.0.1/repository/components/lib and Schedule the task as per your blog, while i am restart the server executing the Schedule,it's not showing nothing in terminal side. Here i am sending my files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<data description="multiple services per each table" enableBatchRequests="false" enableBoxcarring="false" name="salesdetails_DataService" serviceNamespace="http://ws.wso2.org/dataservice" serviceStatus="active"> | |
<config id="default"> | |
<property name="carbon_datasource_name">Signingtest</property> | |
</config> | |
<query id="select_all_salesdetails_query" useConfig="default"> | |
<sql>SELECT productcode, productname, solditems, instock FROM public.salesdetails</sql> | |
<result element="salesdetailsCollection" rowName="salesdetails"> | |
<element column="productcode" name="productcode" xsdType="xs:string"/> | |
<element column="productname" name="productname" xsdType="xs:string"/> | |
<element column="solditems" name="solditems" xsdType="xs:string"/> | |
<element column="instock" name="instock" xsdType="xs:string"/> | |
</result> | |
</query> | |
<query id="insert_salesdetails_query" useConfig="default"> | |
<sql>INSERT INTO public.salesdetails(productcode,productname,solditems,instock) VALUES(?,?,?,?)</sql> | |
<param name="productcode" ordinal="1" paramType="SCALAR" sqlType="STRING" type="IN"/> | |
<param name="productname" ordinal="2" paramType="SCALAR" sqlType="STRING" type="IN"/> | |
<param name="solditems" ordinal="3" paramType="SCALAR" sqlType="STRING" type="IN"/> | |
<param name="instock" ordinal="4" paramType="SCALAR" sqlType="STRING" type="IN"/> | |
</query> | |
<operation name="select_all_salesdetails_operation"> | |
<call-query href="select_all_salesdetails_query"/> | |
</operation> | |
<operation name="insert_salesdetails_operation"> | |
<call-query href="insert_salesdetails_query"> | |
<with-param name="productcode" query-param="productcode"/> | |
<with-param name="instock" query-param="instock"/> | |
<with-param name="solditems" query-param="solditems"/> | |
<with-param name="productname" query-param="productname"/> | |
</call-query> | |
</operation> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.DssSchedlueTask; | |
import java.util.HashMap; | |
import java.util.Map; | |
import org.wso2.carbon.dataservices.core.DataServiceFault; | |
import org.wso2.carbon.dataservices.core.engine.ParamValue; | |
import org.wso2.carbon.dataservices.task.DataTask; | |
import org.wso2.carbon.dataservices.task.DataTaskContext; | |
import org.apache.axiom.om.OMElement; | |
public class ScheduledDataTask_abcCompany implements DataTask { | |
public void execute(DataTaskContext ctx) { | |
System.out.println("Data Task executing..."); | |
String solditems = getSoldItems(); | |
Map<String, ParamValue> params = new HashMap<String, ParamValue>(); | |
params.put("soldItems", new ParamValue(solditems)); | |
params.put("productcode", new ParamValue("0001a3")); | |
try { | |
ctx.invokeOperation("abcCompany", "UpdateSales", params); | |
System.out.println("Successfully updated the database. \tSoldItems = "+solditems); | |
} catch (DataServiceFault e) { | |
System.out.println("Error...."+e.getMessage()); | |
} | |
} | |
private String getSoldItems(){ | |
int soldItems = (int )(Math.random() * 10000 + 1); | |
return Integer.toString(soldItems); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get this work you must add a scheduled task in wso2 dss server, It is clearly explain in the step 6 of the following blog post,
http://itsmeisuru.wordpress.com/2013/11/29/wso2-dss-scheduled-task-example/
I mentioned this in the stackoverflow question also.