protected void process( Processor processor, String item, @Default("Processor.Size.LARGE") Size size, @Default("red") String color, @Default("1") int quantity) { processor.process(item, size, color, quantity); } public void report(@Default("Hello") String message) { System.out.println("Message: " + message); }
public static void main(String[] args) { List<Processor> processors = new ArrayList<>(); processors.add(new Processor(10, 3, false) { @Override protected void doProcess(int i) { System.out.println("Fizz" + "(" + i + ") 3%10"); } }); // add more processors here for(int i = 1; i < 100; i++){ for (Processor processor : processors) { processor.process(i); } } }
/** * Processes the incoming {@link Exchange} and adds the tuple(s) to the underlying streamer. * * @param exchange The Camel Exchange. */ @Override public void process(Exchange exchange) throws Exception { // Extract and insert the tuple(s). if (getMultipleTupleExtractor() == null) { Map.Entry<K, V> entry = getSingleTupleExtractor().extract(exchange); getStreamer().addData(entry); } else { Map<K, V> entries = getMultipleTupleExtractor().extract(exchange); getStreamer().addData(entries); } // If the user has set a response processor, invoke it before finishing. if (resProc != null) resProc.process(exchange); }
@Before public void setUp() throws Exception { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); Processor processor = Mockito.mock(Processor.class); //This line should be added to perform mock for Processor. Mockito.when(processor.process()).thenReturn(<Your returned value>); //ReflectionTestUtils.setField(Controller.class, "processor", processor); }
public void process(Exchange exchange) throws Exception { LOG.info("Before the processor..."); target.process(exchange); LOG.info("After the processor..."); } });
public void process(Exchange exchange) throws Exception { List<Processor> processors = getProcessors(); if (processors.size() == 0) return; processors.get(new Random().nextInt(processors.size())).process(exchange); } }
public void processEvent(Exchange exchange) { LOG.debug("processEvent {}", exchange); try { getProcessor().process(exchange); } catch (Exception e) { LOG.error("Error processing event ", e); } }
@Override public void doResume() throws Exception { log.info("Resuming goal live stream"); // signal the clock is started Exchange exchange = getEndpoint().createExchange(); exchange.getIn().setHeader("action", "clock"); exchange.getIn().setBody(String.valueOf(gameTime.get())); getProcessor().process(exchange); }
@Override protected void doSuspend() throws Exception { log.info("Suspending goal live stream"); // signal the clock is stopped Exchange exchange = getEndpoint().createExchange(); exchange.getIn().setHeader("action", "clock"); exchange.getIn().setBody("Stopped"); getProcessor().process(exchange); }
@Override protected void doStop() throws Exception { log.info("Stopping goal live stream"); timer.cancel(); task = null; // signal the clock is stopped Exchange exchange = getEndpoint().createExchange(); exchange.getIn().setHeader("action", "clock"); exchange.getIn().setBody("Stopped"); getProcessor().process(exchange); super.doStop(); }
protected int poll() throws Exception { List<InactiveDevice> inactiveDeviceList = getInactiveDevices(); Iterator<InactiveDevice> it = inactiveDeviceList.iterator(); while (it.hasNext()) { InactiveDevice inactiveDevice = it.next(); Exchange e = getEndpoint().createExchange(); e.getIn().setBody(inactiveDevice); getProcessor().process(e); } return inactiveDeviceList.size(); }
/** * Strategy to process the mail message. */ protected void processExchange(Exchange exchange) throws Exception { if (LOG.isDebugEnabled()) { MailMessage msg = (MailMessage) exchange.getIn(); LOG.debug("Processing message: {}", MailUtils.dumpMessage(msg.getMessage())); } getProcessor().process(exchange); }
@Override protected void doStart() throws Exception { super.doStart(); List<Exchange> exchanges = twitter4jConsumer.directConsume(); for (int i = 0; i < exchanges.size(); i++) { getProcessor().process(exchanges.get(i)); } } }
@Override public void process(Exchange message) { Object event = message.getIn().getBody(); event = context.getMessagesSerializer().deserialize(event, context.getClassLoader()); try { dispatchMessage(procMock, event, message.getIn().getHeaders()); original.process(message); } catch (Exception e) { throw new RuntimeException("Could not dispatch to the mocked processor: ", e); } } }
@Override public void onTopic(String channel, IRCUser user, String topic) { if (configuration.isOnTopic()) { Exchange exchange = endpoint.createOnTopicExchange(channel, user, topic); try { getProcessor().process(exchange); } catch (Exception e) { handleException(e); } } }
@Override public void onPrivmsg(String target, IRCUser user, String msg) { if (configuration.isOnPrivmsg()) { Exchange exchange = endpoint.createOnPrivmsgExchange(target, user, msg); try { getProcessor().process(exchange); } catch (Exception e) { handleException(e); } } }
@Override public void process(Exchange exchange) throws Exception { getWrappedProcessor().process(exchange); } }
@Override public void process(Exchange exchange) throws Exception { Message msg = exchange.getIn().getMandatoryBody(Message.class); messageTracer.receiveMessage(msg, getEndpoint().getEndpointUri(), (message, span) -> getWrappedProcessor().process(exchange)); }
private void sendEvent(Exchange exchange) { try { getProcessor().process(exchange); } catch (Exception e) { exchange.setException(e); } finally { // log exception if an exception occurred and was not handled if (exchange.getException() != null) { getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException()); } } }
private void processSynchronously(final Exchange exchange, final ChannelHandlerContext ctx, final Object message) { try { consumer.getProcessor().process(exchange); if (consumer.getConfiguration().isSync()) { sendResponse(message, ctx, exchange); } } catch (Throwable e) { consumer.getExceptionHandler().handleException(e); } finally { consumer.doneUoW(exchange); } }