Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

Polling with time as the filter

Hi there,

I'm polling for objects in my space and want to filter them on time .i.e. to check if the expiry time of the object is greater than the current time. I'm currently doing the following:

@EventDriven @Polling @TransactionalEvent public class InstrumentExpirationProcessor { private final Log log = LogFactory.getLog(InstrumentExpirationProcessor.class);

private GigaSpace gigaSpace;

public SQLQuery<InstrumentTemplate> unprocessedData() {
    SQLQuery<InstrumentTemplate> template = new SQLQuery<InstrumentTemplate>(
            "instrumentTemplateStatus = ?", 
    return template;

public InstrumentTemplate processExpiringInstruments(InstrumentTemplate instrumentTemplate) {
    if(System.currentTimeMillis() < instrumentTemplate.getNextExpiryTime()){
        return instrumentTemplate;

The issue I have is that this is sending my CPU up to 100% because it's pulling in the objects all of the time and then comparing the times, as shown above.

I was initially using the @NotifyType(leaseExpire = true) but it only calls this approximately every 10s, but I need it to be instantaneous.

Any ideas or suggestions?

Thanks in advance

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=3663]{quote}

asked 2011-05-10 08:02:56 -0500

robertral gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

Paul, Can you explain why you do that? What's the use case?

answered 2011-05-10 08:11:34 -0500

shay hassidim gravatar image
edit flag offensive delete link more


Once the instrument has come to the end of its life, instrumentTemplate.getNextExpiryTime(), I want to settle this instrument (i.e. it's closing/end price) and then instantly create a new instrument. This worked ok with the Notify(lease expiry) but the time delay wasn't acceptable.

Does this make sense?

robertral gravatar imagerobertral ( 2011-05-10 08:16:26 -0500 )edit

Or is there a way to do this filter in the actual @EventTemplate method?

robertral gravatar imagerobertral ( 2011-05-10 08:17:12 -0500 )edit

You can change the behavior to have finer resolution using space-config.leasemanager.expirationtime_interval. See:
You can make it to scan the expired entries and trigger the notification every second for example.

Another option is to use the Trigger Receive Operation and adapt the Query to use different range each time it polls the space. This will consume relevant objects. In this case you don't need to use the Lease mechanism.

You can find an example for such here:
See the Using a Polling Container section.

shay hassidim gravatar imageshay hassidim ( 2011-05-10 08:25:49 -0500 )edit

Have a look at the following form post, I have offered there a solution with a changing event template:


eitany gravatar imageeitany ( 2011-05-10 08:26:16 -0500 )edit


Thanks for the very prompt reply, really appreciate it
I will check these examples out this afternoon and get back to you.


robertral gravatar imagerobertral ( 2011-05-10 08:30:18 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2011-05-10 08:02:56 -0500

Seen: 45 times

Last updated: May 10 '11