private Observable.Transformer<IndexOperationMessage, IndexOperationMessage> applyCollector(AsyncEventQueueType queueType) { return observable -> observable .collect(() -> new IndexOperationMessage(), (collector, single) -> collector.ingest(single)) .filter(msg -> !msg.isEmpty()) .doOnNext(indexOperation -> { asyncEventService.queueIndexOperationMessage(indexOperation, queueType); }); }
private Observable.Transformer<IndexOperationMessage, IndexOperationMessage> applyCollector(AsyncEventQueueType queueType) { return observable -> observable .collect(() -> new IndexOperationMessage(), (collector, single) -> collector.ingest(single)) .filter(msg -> !msg.isEmpty()) .doOnNext(indexOperation -> { asyncEventService.queueIndexOperationMessage(indexOperation, queueType); }); }
/** * Queue up an indexOperationMessage for multi region execution * @param indexOperationMessage * @param queueType */ public void queueIndexOperationMessage(final IndexOperationMessage indexOperationMessage, AsyncEventQueueType queueType) { // don't try to produce something with nothing if(indexOperationMessage == null || indexOperationMessage.isEmpty()){ return; } final String jsonValue = ObjectJsonSerializer.INSTANCE.toString( indexOperationMessage ); final UUID newMessageId = UUIDGenerator.newTimeUUID(); final int expirationTimeInSeconds = ( int ) TimeUnit.MILLISECONDS.toSeconds( indexProcessorFig.getIndexMessageTtl() ); //write to the map in ES esMapPersistence.putString( newMessageId.toString(), jsonValue, expirationTimeInSeconds ); //now queue up the index message final ElasticsearchIndexEvent elasticsearchIndexEvent = new ElasticsearchIndexEvent(queueFig.getPrimaryRegion(), newMessageId ); //send to the topic so all regions index the batch if (logger.isTraceEnabled()) { logger.trace("Offering ElasticsearchIndexEvent for message {}", newMessageId); } offerTopic( elasticsearchIndexEvent, queueType ); }
if (indexOperationMessage == null || indexOperationMessage.isEmpty()){ throw new RuntimeException( "IndexOperationMessage cannot be null or empty after retrieving from map persistence");
&& single.isEmpty() ){ logger.warn("No index operation messages came back from event processing for eventType: {}, msgId: {}, msgBody: {}", event.getClass().getSimpleName(), message.getMessageId(), message.getStringBody());