简体   繁体   中英

how to persist runtime parameter of a service call then use as parameter for the next service call WSO2 ESB

I am seeking advice on the most appropriate method for the following use case.

I have created a number of services using the WSO2 Data Services Server which I want to run periodically passing in parameters of last run date. ie. the data services has two parameters start and end dates to run the sql against.

I plan to create a service within WSO2 ESB to mediate the execution of these service, combine the results to pass onto another web service. I think I can manage this ;-) I will use a scheduled task to start this at a predefined interval.

Where I am seeking advice is how to keep track of the last successful run time as I need to use this as parameters for the data services web services. My options as I see them

  1. create a config table in my database and create another data services web service to retrieve and persist these values
  2. use vfs transport and somehow persist these values to a text file as xml, csv or json
  3. use some other way like property values in the esb sequence and somehow persist these
  4. any other??

With my current knowledge it would seem that 1 is easiest but it doesn't feel right as I would have to have write access to the database, something I possibly wouldn't normally have when architecting a solution like this in the future, 2 appears like it could work with my limited knowledge of WSO2 ESB to date but is 3 the best option? But as you see from the detail above this is where I start to flounder.

Any suggestions would be most welcome

I do not have much experience with ESB. However I also feel that your first option would be easier to implement.

A related topic was also discussed in WSO2 architecture mailing list recently with subject "[Architecture] Allow ESB to put and update registry properties"

It was discussed to introduce a registry mediator, but I'm not sure it will be implemented soon.

I hope this helps.

As of now there is no direct method to save content to ESB through ESB. But you can always write a custom mediator to do that or use the script mediator to achieve this

Following is the code snippet for the script mediator

<script language="js"><![CDATA[
    importPackage(Packages.org.apache.synapse.config);
    /* creates a new resource */
    mc.getConfiguration().getRegistry().newResource("conf:/store/myStore",false);
    /* update the resource */    
    mc.getConfiguration().getRegistry().updateResource(
                "conf:/store/myStore", mc.getProperty("myProperty").toString());
]]></script>

I've written a blog post on how to do this in ESB 4.8.1. You can find it here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM