/** * Logs a batch of events. * * @param events The batch of events to log **/ public void logBatchFine(String message, List<GatewaySenderEventImpl> events) { if (events != null) { StringBuffer buffer = new StringBuffer(); buffer.append(message); buffer.append(events.size()).append(" events"); buffer.append(" (batch #" + getBatchId()); buffer.append("):\n"); for (GatewaySenderEventImpl ge : events) { buffer.append("\tEvent ").append(ge.getEventId()).append(":"); buffer.append(ge.getKey()).append("->"); // TODO:wan70 remove old code buffer.append(ge.getValueAsString(true)).append(","); buffer.append(ge.getShadowKey()); buffer.append("\n"); } logger.debug(buffer); } }
/** * Sends a batch of messages to the registered <code>AsyncEventListener</code>s. * * @param events The <code>List</code> of events to send * */ protected boolean dispatchBatch(List events) throws GatewaySenderException { if (events.isEmpty()) { return true; } int batchId = this.eventProcessor.getBatchId(); boolean successAll = true; try { for (AsyncEventListener listener : this.eventListeners) { boolean successOne = listener.processEvents(events); if (!successOne) { successAll = false; } } } catch (Exception e) { final String alias = "%s: Exception during processing batch %s"; final Object[] aliasArgs = new Object[] {this, Integer.valueOf(batchId)}; String exMsg = String.format(alias, aliasArgs); GatewaySenderException ge = new GatewaySenderException(exMsg, e); logger.warn(exMsg, ge); throw ge; } return successAll; }
private boolean _dispatchBatch(List events, boolean isRetry) { Exception ex = null; int currentBatchId = this.processor.getBatchId(); connection = getConnection(true); int batchIdForThisConnection = this.processor.getBatchId(); GatewaySenderStats statistics = this.sender.getStatistics();
eventsArr[0] = events; eventsArr[1] = filteredList; this.batchIdToEventsMap.put(getBatchId(), eventsArr); this.batchIdToPDXEventsMap.put(getBatchId(), pdxEventsToBeDispatched); logger.debug( "During normal processing, successfully dispatched {} events (batch #{})", conflatedEventsToBeDispatched.size(), getBatchId()); removeEventFromFailureMap(getBatchId()); } else { if (!skipFailureLogging(getBatchId())) { logger.warn( "During normal processing, unsuccessfully dispatched {} events (batch #{})", new Object[] {filteredList.size(), getBatchId()}); logger.debug( "During normal processing, unsuccessfully dispatched {} events (batch #{})", conflatedEventsToBeDispatched.size(), getBatchId()); logger.debug("Finished processing events (batch #{})", (getBatchId() - 1));
logger.debug( "Failed to dispatch a batch with id {} due to non-fatal exception {}. Retrying in {} ms", this.processor.getBatchId(), t, RETRY_WAIT_TIME);