API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#API Connect
#Applicationintegration
#APIConnect
 View Only
  • 1.  Using catalog properties or UDP to manage catalog wide properties

    Posted Tue August 13, 2024 04:35 PM
    Edited by Lorraine Rizzuto Mon August 19, 2024 08:47 AM

    I have a question how to manage catalog or domain wide properties which are shared by all APIs in the same domain.

    Initially I tried to use the catalog properties and set-variable policy so that these properties become context variables for each API. But I read the note from IBM APIC Documentation that if the catalog property changes we have to re-publish each API.

    Then I decided to develop a UDP which reads key value pairs from a json file and sets these properties as context variables. This UDP is used by all APIs which depend on these properties. If there is a requirement to change the properties we can simply update the json file without re-publishing each API. But I am concerned now with the potential performance impact. With this UDP approach, in run time does each incoming request trigger the process of reading the file and loading properties into the context? These properties are constants and do not change most time.

    Is there any better way to manage the domain or catalog wide properties which can be accessed by each API and properties can get updated in real time without requiring re-publishing each API?



    ------------------------------
    Zhifeng Yu
    Auburn Hills
    ------------------------------



  • 2.  RE: Using catalog properties or UDP to manage catalog wide properties

    Posted Wed August 14, 2024 09:28 AM

    Hi Zhifeng,
    You could have your json file added to your API Gateway document cache policy so it would not need to be read from the file system each time.  That would require a gateway extension override json file to persist this change to the API Gateway object across all of your DataPower appliances in the service.  Another approach would use distributed variables which was introduced in DataPower 10.6.0.0.  Using an xslt you could store the file with an expiration, and when you attempt to read the file from the distributed variable, if you don't get a response you can read it from the file system and save the json object back to the distributed variable.  Your json file updates would be made live the first time you read the file from the file system.  You could also set your context variables in the xslt, just know that in xslt the JSON will need to be converted to JSONx so you can XPath properly to get the values.  Unfortunately, although you can use distributed variables from GatewayScript too, it does not have the expire argument on the set function which is why the xslt is the recommended approach for distributed variables.

    Best Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 3.  RE: Using catalog properties or UDP to manage catalog wide properties

    Posted Thu August 22, 2024 10:56 PM

    Steve, thanks for your advice. That makes sense. Best regards, Zhifeng



    ------------------------------
    Z Yu
    Auburn Hills
    ------------------------------



  • 4.  RE: Using catalog properties or UDP to manage catalog wide properties

    Posted 27 days ago

    Hi Zhifeng,

    I am exploring with the same requirement and had few queries, hope you could you put some info here. 

    1. I am assuming you are pushing the Json file(config) using the UDP from APIC and does some changes on the file in Data Power, does the changes persist in the APIC lifecycle?
    2. Another case You just placed the config json file in DataPower directly and the UDP only does the calling this file for data, in this case if you do the changes on the file does the data persist the apic lifecycle?

    Or if your approach is otherwise, could you pls share some info or sample to view.  Thanks.



    ------------------------------
    pratap vadlapati
    ------------------------------



  • 5.  RE: Using catalog properties or UDP to manage catalog wide properties

    Posted 26 days ago

    Hi Steve,

    If you get a chance, could you comment on the queries.

    All I want to know how to persist the changes on the json(config) file. 



    ------------------------------
    pratap vadlapati
    ------------------------------



  • 6.  RE: Using catalog properties or UDP to manage catalog wide properties

    Posted 26 days ago

    The question I asked before was strictly for how to initialize global configurations required for every API. We ended up with a UDP "init-config" which hard codes very few global variables by using context.set(key, value) without a json file. These global variables are stable but different for each environment. It may not follow the best practice but works effectively for my use case. Hope this helps. Zhifeng



    ------------------------------
    Z Yu
    Auburn Hills
    ------------------------------



  • 7.  RE: Using catalog properties or UDP to manage catalog wide properties

    Posted 25 days ago
    Sure it does, thank you.
    Seems like we cant use dynamic catalog props or json file config for the API without republish.







  • 8.  RE: Using catalog properties or UDP to manage catalog wide properties

    Posted 25 days ago

    Hi Pratap,

    Catalog properties as noted in an earlier post are resolved at publish time.  As far as the gateway is concerned, it receives configuration that has a static value, the value of the catalog property.  I can't speak to what you are doing with a JSON file, but the file needs to be pushed to the gateways although I've seen some clients do that directly and not within the context of an API publish.  I believe I also noted earlier that once the file is one each gateway's filesystem, for performance it could be cached so the file isn't read every time the API executes, but then that of course would require a mechanism to expire the cache, forcing the file to be re-read and re-cached with hopefully updated values.  I believe I also mentioned distributed variables as another mechanism where each variable would have its own expiration, and the distributed variable would be shared across all Gateways in the cluster whereas document cache would have values and expirations unique to each Gateway instance.


    Best Regards,

    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM Retired
    ------------------------------



  • 9.  RE: Using catalog properties or UDP to manage catalog wide properties

    Posted 24 days ago
    Understood Steve. Thanks for your time.
    My use case is to read config from JSON and based on that I want to change my api functionality like reject or accept the call. 

    And that config may changes frequently. And what read this config file from ANY API . 

    My only concern of using the above options.

    I have to do changes in the JSON file for all the data power instances (for instance 3) manually. 

    After that the changes or file will not exist If APIC Domain went through life cycle updates. (If I have keep the file in this domain)

    Even if I push the file through udp , after any APIC upgrade the UDp will be same as the first time version. Changes to the file will not persistent.






  • 10.  RE: Using catalog properties or UDP to manage catalog wide properties

    Posted 20 days ago

    Hi Pratap,

    > I have to do changes in the JSON file for all the data power instances (for instance 3) manually. 

    This is definitely not a best practice.  You need to change the file in one place and you shouldn't be changing the file manually on the local file system since that file, as you note that you're deploying it currently in a user defined policy, manual changes to the file system will not be overwritten by the UDP the next time the policy deploys which depending upon your platform could be every time the Gateway restarts.  I would not recommend deploying the file in your UDP.  Some options:
    1. Do you have a highly available and secure web server?  If so, you could change the file there one time.  You would set the document cache settings for this file so when your code does a urlopen to read the file, you actually only go to your web server once per Gateway and the file contents are cached until the cache expiration.  Since you indicate you change the file often, my suggestion would be to set the cache expiration to the max, as I recall one week in seconds is the max, and then you would have a separate administrative process that after the file is updated, you would send each of your DataPower Gateways a request, for example a SOMA SOAP request or a REST request, to invalidate this one cache entry on each Gateway.  The next file urlopen would read the updated file from the web server and the updated file would be cached.  You could also set the expiration period somewhat low, for example, 30 minutes, which would still minimize the access to the web server, and you could let the cache expiration handle getting the file updated, but in this case you could run the possibility that your DataPower Gateways would expire their cache entry at other times, leading to a potential inconsistency of behavior between the Gateways until all have expired their cache entries or you manually do the SOMA/REST request. The type of settings you have in your JSON file would determine if you can tolerate a short time inconsistency in behavior.

    2. If you don't have a web server, then you should use an external process to push the file to each DataPower Gateway, again a SOMA or REST request to push the updated file.  The above suggestion on the document cache handling would be the same.  Note that the urlopen for a local file will still use cycles which is why having the document cache policy on the file to be present.  You wouldn't have web server latency on a local file but reading the file from the local file system still takes cycles so having this cache policy in place would still help API performance.

    Hope this helps,

    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM Retired
    ------------------------------