@Override protected void doCommit() throws InterruptedException { session.commit(); }
@Override protected void doRollback() throws InterruptedException { session.transfer(flowFiles, failure); session.commit(); }
@Override protected void doCommit() throws InterruptedException { session.transfer(flowFiles, success); session.commit(); }
/** * Will flush the remaining messages when this processor is stopped. */ protected void flushRemainingMessages(ProcessContext processContext) { Message emailMessage; try { while ((emailMessage = this.messageQueue.poll(1, TimeUnit.MILLISECONDS)) != null) { this.transfer(emailMessage, processContext, this.processSession); this.processSession.commit(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); this.logger.debug("Current thread is interrupted"); } }
private boolean commit(final ProcessContext context, final ProcessSession session, int listCount) { boolean willCommit = listCount > 0; if (willCommit) { getLogger().info("Successfully listed {} new files from S3; routing to success", new Object[] {listCount}); session.commit(); } return willCommit; }
private void onTrigger(final ProcessContext context, final ProcessSession session) { readLock.lock(); try { Set<Relationship> available = context.getAvailableRelationships(); while (!available.isEmpty()) { final List<FlowFile> flowFiles = session.get(100); if (flowFiles.isEmpty()) { break; } session.transfer(flowFiles, Relationship.ANONYMOUS); session.commit(); available = context.getAvailableRelationships(); } } finally { readLock.unlock(); } }
@Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { try { doDelete(context, session); } catch (Exception e) { getLogger().error("Error", e); } finally { session.commit(); } }
@Override protected void postProcess(final ProcessContext context, final ProcessSession session, final List<RELPEvent> events) { // first commit the session so we guarantee we have all the events successfully // written to FlowFiles and transferred to the success relationship session.commit(); // respond to each event to acknowledge successful receipt for (final RELPEvent event : events) { respond(event, RELPResponse.ok(event.getTxnr())); } }
protected void postProcess(final ProcessContext context, final ProcessSession session, final List<BeatsEvent> events) { // first commit the session so we guarantee we have all the events successfully // written to FlowFiles and transferred to the success relationship session.commit(); // respond to each event to acknowledge successful receipt for (final BeatsEvent event : events) { respond(event, BeatsResponse.ok(event.getSeqNumber())); } }
private boolean commit(final ProcessContext context, final ProcessSession session, int listCount) { boolean willCommit = listCount > 0; if (willCommit) { getLogger().info("Successfully listed {} new files from GCS; routing to success", new Object[] {listCount}); session.commit(); persistState(context); } return willCommit; } }
@Override public final void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { final ProcessSession session = sessionFactory.createSession(); try { onTrigger(context, session); session.commit(); } catch (final Throwable t) { session.rollback(true); throw t; } }
protected void postProcess(final ProcessContext context, final ProcessSession session, final List<LumberjackEvent> events) { // first commit the session so we guarantee we have all the events successfully // written to FlowFiles and transferred to the success relationship session.commit(); // respond to each event to acknowledge successful receipt for (final LumberjackEvent event : events) { respond(event, LumberjackResponse.ok(event.getSeqNumber())); } }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { final ProcessSession session = sessionFactory.createSession(); try { onTrigger(context, session); session.commit(); } catch (final ProcessException e) { session.rollback(); throw e; } catch (final Throwable t) { session.rollback(); throw new RuntimeException(t); } }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { final ProcessSession session = sessionFactory.createSession(); try { onTrigger(context, session); session.commit(); } catch (final ProcessException e) { session.rollback(); throw e; } catch (final Throwable t) { session.rollback(); throw new RuntimeException(t); } }
/** * Event handler method to perform the required actions when a failure has occurred. The FlowFile is penalized, forwarded to the failure relationship and the context is yielded. * * @param context * - the current process context. * * @param session * - the current process session. * @param flowFile * - the FlowFile that has failed to have been processed. */ protected void onFailure(final ProcessContext context, final ProcessSession session, final FlowFile flowFile) { session.transfer(session.penalize(flowFile), REL_FAILURE); session.commit(); context.yield(); }
/** * event handler method to perform the required actions when a failure has occurred. The FlowFile is penalized, forwarded to the failure relationship and the context is yielded. * * @param context * - the current process context. * * @param session * - the current process session. * @param flowFile * - the FlowFile that has failed to have been processed. */ protected void onFailure(final ProcessContext context, final ProcessSession session, final FlowFile flowFile) { session.transfer(session.penalize(flowFile), REL_FAILURE); session.commit(); context.yield(); }
public static void onTrigger( ProcessContext context, ProcessSessionFactory sessionFactory, ComponentLog logger, OnTrigger onTrigger, RollbackSession rollbackSession) throws ProcessException { final ProcessSession session = sessionFactory.createSession(); try { onTrigger.execute(session); session.commit(); } catch (final Throwable t) { logger.error("{} failed to process due to {}; rolling back session", new Object[]{onTrigger, t}); rollbackSession.rollback(session, t); throw t; } } }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { final ProcessSession session = sessionFactory.createSession(); try { onTrigger(context, session); session.commit(); } catch (final Throwable t) { getLogger() .error("{} failed to process due to {}; rolling back session", new Object[]{this, t}); session.rollback(true); throw t; } }
@Override public final void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { if (processSessionFactory == null) { processSessionFactory = sessionFactory; } ProcessSession session = sessionFactory.createSession(); try { onTrigger(context, session); session.commit(); } catch (final Throwable t) { getLogger().error("{} failed to process due to {}; rolling back session", new Object[]{this, t}); session.rollback(true); throw t; } }
@Override public void accept(final JMSResponse response) { if (response == null) { return; } FlowFile flowFile = processSession.create(); flowFile = processSession.write(flowFile, out -> out.write(response.getMessageBody())); final Map<String, String> jmsHeaders = response.getMessageHeaders(); final Map<String, String> jmsProperties = response.getMessageProperties(); flowFile = ConsumeJMS.this.updateFlowFileAttributesWithJMSAttributes(jmsHeaders, flowFile, processSession); flowFile = ConsumeJMS.this.updateFlowFileAttributesWithJMSAttributes(jmsProperties, flowFile, processSession); flowFile = processSession.putAttribute(flowFile, JMS_SOURCE_DESTINATION_NAME, destinationName); processSession.getProvenanceReporter().receive(flowFile, destinationName); processSession.transfer(flowFile, REL_SUCCESS); processSession.commit(); } });