@Override protected void doProcess(JCas jCas) throws AnalysisEngineProcessException { Map<String, Object> json = SingleDocumentConsumerFormat.formatCas( jCas, fields, contentHashAsId, getMonitor(), getSupport()); String id = (String) json.getOrDefault("externalId", ""); // Persist to ElasticSearch addDocument(id, json); }
@Override protected void doProcess(final JCas jCas) throws AnalysisEngineProcessException { Map<String, Object> output = SingleDocumentConsumerFormat.formatCas( jCas, new DefaultFields(), contentHashAsId, getMonitor(), getSupport()); // Persist to ActiveMQ try { String json = MAPPER.writeValueAsString(output); String id = (String) output.getOrDefault("externalId", ""); Message msg = samr.getSession().createTextMessage(json); Destination destination = samr.getSession().createTopic(endpoint); samr.getProducer().send(destination, msg); getMonitor().debug("Document with id {} sent to ActiveMQ", id); } catch (JsonProcessingException e) { getMonitor() .error("Unable to parse object to JSON - document will not be sent to ActiveMQ", e); } catch (final JMSException e) { getMonitor().error("Unable to send document to ActiveMQ", e); } } }
@Override protected void doProcess(final JCas jCas) throws AnalysisEngineProcessException { Map<String, Object> output = SingleDocumentConsumerFormat.formatCas( jCas, new DefaultFields(), contentHashAsId, getMonitor(), getSupport()); // Persist to ActiveMQ try { String json = MAPPER.writeValueAsString(output); String id = (String) output.getOrDefault("externalId", ""); Message msg = samr.getSession().createTextMessage(json); Destination destination = samr.getSession().createTopic(endpoint); samr.getProducer().send(destination, msg); getMonitor().debug("Document with id {} sent to ActiveMQ", id); } catch (JsonProcessingException e) { getMonitor() .error("Unable to parse object to JSON - document will not be sent to ActiveMQ", e); } catch (final JMSException e) { getMonitor().error("Unable to send document to ActiveMQ", e); } } }