Ignition 8.1.17 - after upgrading from 8.1.16, pages message sent doesn't trigger perspective message handler?

Hi @PGriffith,

I’ve upgraded an application from Ignition 8.1.16 to Ignition 8.1.17

I have a module that send message to perspective pages.
All works fine in 8.1.16, but after upgrading in 8.1.17, the message are not sent or received in the event bus.

Does anything change in the way to send page’s message ?

The code used by the module to send message:

    public void sendCallbackMessage(String strSessionId,String pageId,String sessionName,Dataset data) {
        try {
            UUID sessionId = UUID.fromString(strSessionId);
            perspectiveContext.getSessionMonitor().findSession(sessionId).ifPresent(session -> {

                Optional<PageModel> pageModel = session.findPage(pageId);
                if (pageModel.isPresent()){

                    PyDictionary payloadMap = new PyDictionary();
                    QualifiedValue value = new BasicQualifiedValue(data);
                    payloadMap.put("data", value);

                    UserScopeMessageEvent message = new UserScopeMessageEvent(sessionName, payloadMap);

                    logger.debug("sendCallbackMessage() send to sessionName={} - sessionId={} - pageId={} - data={}",
                            sessionName,
                            sessionId.toString(),
                            pageId,
                            value);

                    session.queue().submit(() -> pageModel.get().getPageEventBus().post(message));

                } else {
                    logger.error("sendCallbackMessage() - sessionId={} - pageId={} not found !",
                            sessionId.toString(),
                            pageId);
                }
            });
        } catch (Exception e) {
            logger.error("sendCallbackMessage() - Exception : {}",e);
        }
    }

According to gateway and browser logs, session id and page id are OK,
nevertheless the message handler that is no more triggered since upgrading in 8.1.17:

Perspective page message handler:

Instead of subscribing to the page eventbus, subscribe to the page’s event manager (you’ll have to bump your SDK version). There was a catastrophic performance cliff in Guava’s eventbus, so we had to migrate away. The API is roughly the same, but the internals are different.

Thanks a lot @PGriffith !

I suppose that it’s the same for session message, I have to use event Manager instead of event bus:

before 8.1.17:

	perspectiveContext.getSessionMonitor().findSession(sessionId).ifPresent(session -> {
			PyDictionary payloadMap = new PyDictionary();
			payloadMap.put("sessionId", sessionId.toString());
			payloadMap.put("id", id);
			payloadMap.put("qv", qv);
			UserScopeMessageEvent message = new UserScopeMessageEvent(messageHandler, payloadMap);
			logger.debug("SessionEventBus().post : sessionId={}, id={}, qv={}",sessionId.toString(),id,qv);
			session.queue().submit(() -> session.getEventBus().post(message));
	});

from 8.1.17:

session.queue().submit(() -> session.getEventManager().post(message));
1 Like

Yeah, pretty much everything in Perspective was refactored to have the two side by side. I think we’re planning to remove the eventbus stuff in Perspective in 8.2.X, but I’m not positive on that.

1 Like

is that required to depend on the Perspective module !?

If you plan to use Perspective APIs in your code, you must do two things:

  1. At compile time of your module, provide the appropriate Perspective SDK dependencies via your build system of choice.
  2. Declare a dependency on the Perspective module in your module.xml, so that Ignition knows to load your code (on the Gateway, at least) within an appropriate classloader.

If you want to handle Perspective being optional, things get somewhat more complicated and can require reflection to handle cleanly.

1 Like

Sorry for bothering you,
there is an Archetype for Perspective Module To import an empty Template To write My code there.
Thanks in Advanced

No, there are no Maven archetypes for a Perspective component. We use Gradle internally, and no one (to my knowledge) has yet figured out how to build a Perspective component with Maven.

There are two public examples of a Perspective component built using Gradle:

1 Like

Thanks PGriffith :heart: