@Override public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { channel.setSession(session); try { sink.process(); } catch (EventDeliveryException ex) { throw new ProcessException("Flume event delivery failed", ex); } }
@OnScheduled public void onScheduled(final SchedulingContext context) { try { channel = new NifiSinkSessionChannel(SUCCESS, FAILURE); channel.start(); sink = SINK_FACTORY.create( context.getProperty(SOURCE_NAME).getValue(), context.getProperty(SINK_TYPE).getValue()); sink.setChannel(channel); String flumeConfig = context.getProperty(FLUME_CONFIG).getValue(); String agentName = context.getProperty(AGENT_NAME).getValue(); String sinkName = context.getProperty(SOURCE_NAME).getValue(); Configurables.configure(sink, getFlumeSinkContext(flumeConfig, agentName, sinkName)); sink.start(); } catch (Throwable th) { getLogger().error("Error creating sink", th); throw Throwables.propagate(th); } }
@OnStopped public void stopped() { sink.stop(); channel.stop(); }