I found out the hard way that if I create 2 CQ’s on the same region with the same query string, each with a different listener, that the 2nd one will overwrite the first one. However, what I need is that when I write a single event into a region that multiple listeners fire.
Question: if I have an existing CQ and I want to add another listener to it, do I need to destroy the first listener and recreate a new CQ with 2 listeners? Would be nice to be able to just add a listener. private CqQuery addListenerToExistingCq(QueryService queryService, CqQuery cqQuery, DomainEventListener aListener) { CqAttributes cqa = cqQuery.getCqAttributes(); // Add new listener to existing query CqAttributesFactory cqAf = new CqAttributesFactory(cqa); cqAf.addCqListener(aListener); cqa = cqAf.create(); String cqName = cqQuery.getName(); String query = cqQuery.getQueryString(); try { if (cqQuery != null) { if (cqQuery.isRunning()) { cqQuery.stop(); cqQuery.close(); } } cqQuery = queryService.newCq(cqName, query, cqa); SelectResults sResults = cqQuery.executeWithInitialResults(); Thanks, Wes Williams