Topic
  • 3 replies
  • Latest Post - ‏2016-11-04T13:19:00Z by fjb_saper
datafile4
datafile4
5 Posts

Pinned topic Sequential access to global cache

‏2016-11-02T06:07:42Z | broker cache

I want to use value in global cache as iterator. Iterator will be updated by two flows and situation may occur that iterator will be updated at the same time. How to avoid this situation ? Can I avoid it using Java for lock iterator (as it is done for threads) or somehow configure cache ? 

P.S  I am using Integration Bus V9.0.0.5

Updated on 2016-11-02T07:51:12Z at 2016-11-02T07:51:12Z by datafile4
  • lancelotlinc
    lancelotlinc
    485 Posts

    Re: Sequential access to global cache

    ‏2016-11-02T11:42:18Z  

    You should use a Mutex or a Semaphore. And no reason to use _Global_ cache, you can use _local_ cache if you choose.

     

     

    Example: Using mutexes in Java

    http://publib.boulder.ibm.com/html/as400/v4r5/ic2931/info/RZAHWEX4RX.HTM

     

     

  • datafile4
    datafile4
    5 Posts

    Re: Sequential access to global cache

    ‏2016-11-02T12:30:59Z  

    You should use a Mutex or a Semaphore. And no reason to use _Global_ cache, you can use _local_ cache if you choose.

     

     

    Example: Using mutexes in Java

    http://publib.boulder.ibm.com/html/as400/v4r5/ic2931/info/RZAHWEX4RX.HTM

     

     

    Oh, sorry, variable must be iterated by flows in different integration servers. 

    In Integration Bus V10 we can set pessimistic locking for ObjectGrid and I decided that this is similar to what I need. But on the server we have Integration Bus V9.0.0.5 and there is not options for set locking on cache, and I have no way to upgrade Bus. Integrated tools are prefered. 

  • fjb_saper
    fjb_saper
    159 Posts

    Re: Sequential access to global cache

    ‏2016-11-04T13:19:00Z  

    Oh, sorry, variable must be iterated by flows in different integration servers. 

    In Integration Bus V10 we can set pessimistic locking for ObjectGrid and I decided that this is similar to what I need. But on the server we have Integration Bus V9.0.0.5 and there is not options for set locking on cache, and I have no way to upgrade Bus. Integrated tools are prefered. 

    You may have to double up your cache. One entry for the data, one entry for a lock object.

    At a high level, here is what you need to do.

    The lock object needs to get accessed and checked, then if available for locking, updated and checked. if the check after update contains the correct thread id you can go forward otherwise somebody else has the lock.

    Don't forget to release the lock and update the lock object accordingly when you're done... and may be brake the lock if the lock duration is over xxx seconds?