Package org.springframework.messaging

Examples of org.springframework.messaging.PollableChannel


    }
    logger.info("Populated directory with files");
    Thread.sleep(2000);
    logger.info("Starting Spring Integration Sequential File processing");
    ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("META-INF/spring/integration/sequentialFileProcessing-config.xml");
    PollableChannel filesOutChannel = ac.getBean("filesOutChannel", PollableChannel.class);
    for (int i = 0; i < fileCount; i++) {
      logger.info("Finished processing " + filesOutChannel.receive(10000).getPayload());
    }
    ac.stop();
  }
View Full Code Here


    }
    logger.info("Populated directory with files");
    Thread.sleep(2000);
    logger.info("Starting Spring Integration Sequential File processing");
    ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("/META-INF/spring/integration/concurrentFileProcessing-config.xml");
    PollableChannel filesOutChannel = ac.getBean("filesOutChannel", PollableChannel.class);
    for (int i = 0; i < fileCount; i++) {
      logger.info("Finished processing " + filesOutChannel.receive(10000).getPayload());
    }
    ac.stop();
  }
View Full Code Here

    String file2 = "b.txt";
    String file3 = "c.bar";
    new File("local-dir", file1).delete();
    new File("local-dir", file2).delete();
    try {
      PollableChannel localFileChannel = context.getBean("receiveChannel", PollableChannel.class);
      @SuppressWarnings("unchecked")
      SessionFactory<LsEntry> sessionFactory = context.getBean(CachingSessionFactory.class);
      template = new RemoteFileTemplate<LsEntry>(sessionFactory);
      SftpTestUtils.createTestFiles(template, file1, file2, file3);

      SourcePollingChannelAdapter adapter = context.getBean(SourcePollingChannelAdapter.class);
      adapter.start();

      Message<?> received = localFileChannel.receive();
      assertNotNull("Expected file", received);
      System.out.println("Received first file message: " + received);
      received = localFileChannel.receive();
      assertNotNull("Expected file", received);
      System.out.println("Received second file message: " + received);
      received = localFileChannel.receive(1000);
      assertNull("Expected null", received);
      System.out.println("No third file was received as expected");
    }
    finally {
      SftpTestUtils.cleanUp(template, file1, file2, file3);
View Full Code Here

  @Test
  public void demoControlBus(){
    ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext(
        "/META-INF/spring/integration/ControlBusDemo-context.xml");
    MessageChannel controlChannel = ac.getBean("controlChannel", MessageChannel.class);
    PollableChannel adapterOutputChanel = ac.getBean("adapterOutputChanel", PollableChannel.class);
    logger.info("Received before adapter started: " + adapterOutputChanel.receive(1000));
    controlChannel.send(new GenericMessage<String>("@inboundAdapter.start()"));
    logger.info("Received before adapter started: " + adapterOutputChanel.receive(1000));
    controlChannel.send(new GenericMessage<String>("@inboundAdapter.stop()"));
    logger.info("Received after adapter stopped: " + adapterOutputChanel.receive(1000));
    ac.close();
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void runDemo(){
    ConfigurableApplicationContext ac =
      new ClassPathXmlApplicationContext("META-INF/spring/integration/FeedInboundChannelAdapterSample-context.xml");
    PollableChannel feedChannel = ac.getBean("feedChannel", PollableChannel.class);
    for (int i = 0; i < 10; i++) {
      Message<SyndEntry> message = (Message<SyndEntry>) feedChannel.receive(1000);
      if (message != null){
        SyndEntry entry = message.getPayload();
        System.out.println(entry.getPublishedDate() + " - " + entry.getTitle());
      }
      else {
View Full Code Here

  private static Logger logger = Logger.getLogger(HelloWorldApp.class);

  public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/helloWorldDemo.xml", HelloWorldApp.class);
    MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class);
    PollableChannel outputChannel = context.getBean("outputChannel", PollableChannel.class);
    inputChannel.send(new GenericMessage<String>("World"));
    logger.info("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload());
  }
View Full Code Here

  @Test
  public void runDemo() throws Exception{
    ConfigurableApplicationContext ctx =
      new ClassPathXmlApplicationContext("META-INF/spring/integration/FtpInboundChannelAdapterSample-context.xml");

    PollableChannel ftpChannel = ctx.getBean("ftpChannel", PollableChannel.class);

    Message<?> message1 = ftpChannel.receive(2000);
    Message<?> message2 = ftpChannel.receive(2000);
    Message<?> message3 = ftpChannel.receive(1000);

    LOGGER.info(String.format("Received first file message: %s.", message1));
    LOGGER.info(String.format("Received second file message: %s.", message2));
    LOGGER.info(String.format("Received nothing else: %s.", message3));
View Full Code Here

    //mock
    StepExecution masterStepExecution = mock(StepExecution.class);
    StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
    MessagingTemplate operations = mock(MessagingTemplate.class);
    Message message = mock(Message.class);
    PollableChannel replyChannel = mock(PollableChannel.class);
    //when
    HashSet<StepExecution> stepExecutions = new HashSet<StepExecution>();
    stepExecutions.add(new StepExecution("step1", new JobExecution(5l)));
    when(stepExecutionSplitter.split((StepExecution) anyObject(), eq(1))).thenReturn(stepExecutions);
    when(message.getPayload()).thenReturn(Collections.emptyList());
View Full Code Here

    getMessageBus().unbindConsumers("tap:job:" + jobName);
  }

  private void waitForJobCompletion(String jobName) {
    // could match on parameters if necessary (for disambiguation of concurrent executions)
    PollableChannel channel = jobTapChannels.get(jobName);
    Message<?> message = null;
    do {
      message = channel.receive(10000);
      if (message != null) {
        Object payload = message.getPayload();
        if (payload instanceof JobExecution) {
          // could add a waitForJobLaunch that returns as soon as it sees STARTED status
          if (BatchStatus.COMPLETED.equals(((JobExecution) payload).getStatus())) {
View Full Code Here

        new ModuleDescriptor.Builder().setGroup(moduleGroupName).setIndex(moduleIndex).setModuleDefinition(
            ModuleDefinitions.dummy("testjob", ModuleType.job)).build());

    MessageChannel stepsOut = new DirectChannel();
    when(module.getComponent("stepExecutionRequests.output", MessageChannel.class)).thenReturn(stepsOut);
    PollableChannel stepResultsIn = new QueueChannel();
    when(module.getComponent("stepExecutionReplies.input", MessageChannel.class)).thenReturn(stepResultsIn);
    PollableChannel stepsIn = new QueueChannel();
    when(module.getComponent("stepExecutionRequests.input", MessageChannel.class)).thenReturn(stepsIn);
    MessageChannel stepResultsOut = new DirectChannel();
    when(module.getComponent("stepExecutionReplies.output", MessageChannel.class)).thenReturn(stepResultsOut);
    jobPartitionerPlugin.preProcessModule(module);
    jobPartitionerPlugin.postProcessModule(module);
    checkBusBound(messageBus);
    stepsOut.send(new GenericMessage<String>("foo"));
    Message<?> stepExecutionRequest = stepsIn.receive(10000);
    assertThat(stepExecutionRequest, hasPayload("foo"));
    stepResultsOut.send(MessageBuilder.withPayload("bar")
        .copyHeaders(stepExecutionRequest.getHeaders()) // replyTo
        .build());
    assertThat(stepResultsIn.receive(10000), hasPayload("bar"));
View Full Code Here

TOP

Related Classes of org.springframework.messaging.PollableChannel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.