-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
My web application get notification from outside, and I want to display this info for the logged in users. I tried an EventQue based solution as follows:
EventQueue<Event> queue = EventQueues.lookup("myQueue", EventQueues.APPLICATION, true);
queue.publish(new Event("myEvent", null, someData));
Unfortunately it is not working in a non-ZK message listener class.
What would be the suggested way to trigger a(n application scoped) ZK Event from a non-ZK class?
Hi takach,
When do you want to publish an event? in a thread?
Hi jimmyshiau,
My application rus on Tomcat, and a Quartz Job listens for outside notifications. It is a thread dedicated to this (or all Quartz) Job. At present it has nothing to do with ZK. would like to make possible to reach a ZK EventQueue from this Job and publish an event to it.
Read about HTML5 WebSockets. There are a few OS frameworks out (jWebsocket, Atmosphere) that can help you.
Thank you terrtornado,
Unfortunately HTML5 is not an option for us, by browser compatibility and because it is not a new application and I am restricted to the existing architecture.
The event what I wan to push to the client ZK pages comes either from an administrator page (also ZK), or from outside through a Quartz Job. I can publish an Event to an EventQueue on the admin page, and I can also capture it on the client pages. I want to complete this solution.
So my question is: is it possible to reach the ZK EventQueue from the non-ZK Code.
I had the same problem once... and due to the deadline i had... the fastest ignorant solution i was able to get out from my magic hat was to place a secured .zul file like:
<zk> <div id="resultContainer" apply="duty.core.services.rest.ServicesController" ></div> </zk>
public class ServicesController extends GenericAutowireComposer { private final static Logger _log = Logger.getLogger(ServicesController.class); private final static String SERVICE = "service"; @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); String service = Executions.getCurrent().getParameter(SERVICE); if (StringUtils.isEmpty(service)) { _log.error("no service specified"); throw new IllegalArgumentException("invalid service called - empty"); } else { ServiceDescriptor serviceDescriptor = (ServiceDescriptor) SpringUtil.getBean(service); // ... WHATEVAH like yours: EventQueue<Event> queue = EventQueues.lookup("myQueue", EventQueues.APPLICATION, true); queue.publish(new Event("myEvent", null, someData)); } } }
So... i was able to call via a simple HttpURLConnection my .zul file which is finally able to trigger the EventQueue for example.
For sure is not elegant… but it damn worked for me :D
Giovanni
Asked: 2012-11-30 11:50:58 +0800
Seen: 100 times
Last updated: Dec 06 '12