protected GatewayEventCallbackDispatcher(GatewayEventProcessor eventProcessor) { this.eventProcessor = eventProcessor; this.logger = eventProcessor.getLogger(); initializeEventListeners(); }
protected void initializeEventListeners() { for (Iterator i = this.eventProcessor.getGateway().getListeners().iterator(); i.hasNext(); ) { registerGatewayEventListener((GatewayEventListener) i.next()); } }
protected GatewayEventDispatcher initializeEventDispatcher() { GatewayEventDispatcher dispatcher = null; if (getGateway().hasEndpoints()) { dispatcher = new GatewayEventRemoteDispatcher(this); } else { dispatcher = new GatewayEventCallbackDispatcher(this); } return dispatcher; }
/** * Dispatches a batch of messages to all registered <code>GatewayEventListener</code>s. * @param events The <code>List</code> of events to send * @param removeFromQueueOnException Unused. * * @return whether the batch of messages was successfully processed */ public boolean dispatchBatch(List events, boolean removeFromQueueOnException) { GatewayStats statistics = this.eventProcessor.getGateway().getStatistics(); boolean success = false; try { // Send the batch to the corresponding Gateway long start = statistics.startTime(); success = dispatchBatch(events); statistics.endBatch(start, events.size()); } catch (GatewayException e) { // Do nothing in this case. The exception has already been logged. } catch (CancelException e) { this.eventProcessor.setIsStopped(true); throw e; } catch (Exception e) { this.logger.severe(LocalizedStrings.GatewayEventCallbackDispatcher_STOPPING_THE_PROCESSOR_BECAUSE_THE_FOLLOWING_EXCEPTION_OCCURRED_WHILE_PROCESSING_A_BATCH, e); this.eventProcessor.setIsStopped(true); } return success; }