@Override public void yield() { if (processContext != null) { processContext.yield(); } }
@Override public void yield() { if (processContext != null) { processContext.yield(); } }
@Override public void yield() { if (processContext != null) { processContext.yield(); } }
@Override public void yield() { processContext.yield(); }
@Override public void yield() { if (processContext != null) { processContext.yield(); } }
private static FlowFile penalize(final ProcessContext context, final ProcessSession session, final FlowFile flowFile, final ErrorTypes.Penalty penalty) { switch (penalty) { case Penalize: return session.penalize(flowFile); case Yield: context.yield(); } return flowFile; }
/** * Receives message from the internal queue filling up the queue if * necessary. */ protected Message receiveMessage(ProcessContext context) { Message emailMessage = null; try { this.fillMessageQueueIfNecessary(context); emailMessage = this.messageQueue.poll(1, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { context.yield(); this.logger.error("Failed retrieving messages from EWS.", e); Thread.currentThread().interrupt(); this.logger.debug("Current thread is interrupted"); } return emailMessage; }
@Override public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException { if (this.delegatingMessageHandler == null) { this.delegatingMessageHandler = new NiFiDelegatingMessageHandler(sessionFactory); } this.run(context); context.yield(); }
@OnScheduled public void onScheduled(ProcessContext context) { try { initializeResolver(context); } catch (Exception e) { context.yield(); throw new ProcessException("Failed to initialize the JNDI DNS resolver server", e); } }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) { sessionFactoryReference.compareAndSet(null, sessionFactory); for (final String id : findOldFlowFileIds(context)) { final FlowFileEntryTimeWrapper wrapper = flowFileMap.remove(id); if (wrapper != null) { getLogger().warn("failed to received acknowledgment for HOLD with ID {} sent by {}; rolling back session", new Object[] {id, wrapper.getClientIP()}); wrapper.session.rollback(); } } context.yield(); }
@Override public final void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { if (processSessionFactory == null) { processSessionFactory = sessionFactory; } if (!isProcessorRegisteredToService()) { try { registerProcessorToService(context, webSocketService -> onWebSocketServiceReady(webSocketService)); } catch (IOException|WebSocketConfigurationException e) { // Deregister processor if it failed so that it can retry next onTrigger. deregister(); context.yield(); throw new ProcessException("Failed to register processor to WebSocket service due to: " + e, e); } } context.yield();//nothing really to do here since handling WebSocket messages is done at ControllerService. }
/** * 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(); }
@Override public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { final ComponentLog logger = getLogger(); WrappedMessageConsumer wrappedConsumer = consumerQueue.poll(); if (wrappedConsumer == null) { try { wrappedConsumer = JmsFactory.createQueueMessageConsumer(context); } catch (JMSException e) { logger.error("Failed to connect to JMS Server due to {}", e); context.yield(); return; } } try { super.consume(context, session, wrappedConsumer); } finally { if (!wrappedConsumer.isClosed()) { consumerQueue.offer(wrappedConsumer); } } }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { if (smtp == null) { try { final SMTPServer server = prepareServer(context, sessionFactory); server.start(); getLogger().debug("Started SMTP Server on port " + server.getPort()); smtp = server; } catch (final Exception ex) {//have to catch exception due to awkward exception handling in subethasmtp smtp = null; getLogger().error("Unable to start SMTP server due to " + ex.getMessage(), ex); } } context.yield();//nothing really to do here since threading managed by smtp server sessions }
@Override public void onTrigger(ProcessContext context, ProcessSession processSession) throws ProcessException { if(this.messageQueue == null){ int fetchSize = context.getProperty(FETCH_SIZE).evaluateAttributeExpressions().asInteger(); this.messageQueue = new ArrayBlockingQueue<>(fetchSize); } this.folderName = context.getProperty(FOLDER).evaluateAttributeExpressions().getValue(); Message emailMessage = this.receiveMessage(context); if (emailMessage != null) { this.transfer(emailMessage, context, processSession); } else { //No new messages found, yield the processor context.yield(); } }
public static <FCT extends RollbackOnFailure> void onTrigger( ProcessContext context, ProcessSessionFactory sessionFactory, FCT functionContext, ComponentLog logger, PartialFunctions.OnTrigger onTrigger) throws ProcessException { PartialFunctions.onTrigger(context, sessionFactory, logger, onTrigger, (session, t) -> { // If RollbackOnFailure is enabled, do not penalize processing FlowFiles when rollback, // in order to keep those in the incoming relationship to be processed again. final boolean shouldPenalize = !functionContext.isRollbackOnFailure(); session.rollback(shouldPenalize); // However, keeping failed FlowFile in the incoming relationship would retry it too often. // So, administratively yield the process. if (functionContext.isRollbackOnFailure()) { logger.warn("Administratively yielding {} after rolling back due to {}", new Object[]{context.getName(), t}, t); context.yield(); } }); }
@Override public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException { if (eventProcessorHost == null) { try { registerEventProcessor(context); } catch (IllegalArgumentException e) { // In order to show simple error message without wrapping it by another ProcessException, just throw it as it is. throw e; } catch (Exception e) { throw new ProcessException("Failed to register the event processor due to " + e, e); } processSessionFactory = sessionFactory; readerFactory = context.getProperty(RECORD_READER).asControllerService(RecordReaderFactory.class); writerFactory = context.getProperty(RECORD_WRITER).asControllerService(RecordSetWriterFactory.class); } // After a EventProcessor is registered successfully, nothing has to be done at onTrigger // because new sessions are created when new messages are arrived by the EventProcessor. context.yield(); }
private void initializeClient(ProcessContext context) { // NOTE: This method is called when isConnected returns false which can happen when the client is null, or when it is // non-null but not connected, so we need to handle each case and only create a new client when it is null try { if (mqttClient == null) { logger.debug("Creating client"); mqttClient = createMqttClient(broker, clientID, persistence); mqttClient.setCallback(this); } if (!mqttClient.isConnected()) { logger.debug("Connecting client"); mqttClient.connect(connOpts); } } catch (MqttException e) { logger.error("Connection to {} lost (or was never connected) and connection failed. Yielding processor", new Object[]{broker}, e); context.yield(); } }
private void initializeClient(ProcessContext context) { // NOTE: This method is called when isConnected returns false which can happen when the client is null, or when it is // non-null but not connected, so we need to handle each case and only create a new client when it is null try { if (mqttClient == null) { logger.debug("Creating client"); mqttClient = createMqttClient(broker, clientID, persistence); mqttClient.setCallback(this); } if (!mqttClient.isConnected()) { logger.debug("Connecting client"); mqttClient.connect(connOpts); mqttClient.subscribe(topicFilter, qos); } } catch (MqttException e) { logger.error("Connection to {} lost (or was never connected) and connection failed. Yielding processor", new Object[]{broker}, e); context.yield(); } }