[RESOLVED] pushEvent does not work (?)

Hi Tangoers,

I bump into an annoying bug – looks like push events from a server code does not work.

Here is my Java server:


@Attribute(pushChangeEvent = true)
@AttributeProperties(description = "System.currentTimeMillis")
public long getRegister15() {
        return System.currentTimeMillis();
}

//inject DeviceManager
//initialize ScheduledExecutorService

@Init
public void init() throws Exception {
        exec.scheduleWithFixedDelay(new Runnable() {
            @Override
            public void run() {
                try {
                    long value = System.currentTimeMillis();
                    System.out.println("Sending new value = " + value);
                    deviceManager.pushEvent("register15", new AttributeValue(value), EventType.CHANGE_EVENT);
                } catch (DevFailed devFailed) {
                    DevFailedUtils.printDevFailed(devFailed);
                }
            }
        }, (long) (Math.random() * 100L), 50L, TimeUnit.MILLISECONDS);
}

When a client subscribes to the "register15"'s change event it gets no values.

Quick investigation showed that EventManager is not initialized. If look into EventManager#pushAttributeEvent:


xlogger.entry();
final String fullName = EventUtilities.buildEventName(deviceName, attributeName, eventType);
final EventImpl eventImpl = getEventImpl(fullName);//this returns null because isInitialized is false. See below
if (eventImpl != null) {
    // Ooops… nothing goes outside, because eventImpl is null!
    eventImpl.pushAttributeEvent(eventSocket, fullName);
}
xlogger.exit();

and in EventManager#getEventImpl:


//isInitialized is false
if (!isInitialized) {
     return null;
}

// Check if subscribed
EventImpl eventImpl = eventImplMap.get(fullName);

even though I deliberately call EventManager#initialize using reflection then it still fails, as eventImplMap does not contain anything. eventImplMap is only updated in getConnectionParamateres which in turn is only called from AdminDevice.

So the question is – how to make push event mechanism to work?

NOTE: pushInterfaceChangeEvent does not work neither (called after device's @Init method in DeviceImpl#doInit)

Thank you in advance.

Igor

P.S. JTangoServer-9.0.3, Tango 8 (Debian 7)
Edited 8 years ago
UPDATE

Finally got it! Just forgot to add checkChangeEvent = false to the @Attribute annotation:


@Attribute(pushChangeEvent = true, checkChangeEvent = false)
private long register15;
Edited 8 years ago
 
Register or login to create to post a reply.