Package org.springframework.integration

Examples of org.springframework.integration.MessageChannel


  @Test
  public void testOrder() {
    final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
    final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
    final MessageUpdatingServiceActivator messageUpdater = context.getBean( "messageUpdater", MessageUpdatingServiceActivator.class );
    final MessageChannel voldemortOrderChannel = context.getBean( "voldemortOrderChannel", MessageChannel.class );

    // given
    final Person lukasz = new Person( "lukasz", "Lukasz", "Antoniak" );
    final Person copy = new Person( "lukasz", "Lukasz", "Antoniak" );

    // when
    final Message<Person> message = MessageBuilder.withPayload( lukasz ).build();
    voldemortOrderChannel.send( message );

    // then
    messageUpdater.updatePerson( copy );
    final Versioned found = storeClient.get( lukasz.getId() );
    Assert.assertEquals( copy, found.getValue() );
View Full Code Here


  }

  @Test
  public void testAggregatorWithShutdown() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortMessageStoreAggregationTest-context.xml", getClass() );
    MessageChannel input = context.getBean( "inputChannel", MessageChannel.class );
    QueueChannel output = context.getBean( "outputChannel", QueueChannel.class );

    Message<?> message1 = MessageBuilder.withPayload( "1" )
                      .setSequenceNumber( 1 ).setSequenceSize( 3 ).setCorrelationId( 1 ).build();
    Message<?> message2 = MessageBuilder.withPayload( "2" )
                      .setSequenceNumber( 2 ).setSequenceSize( 3 ).setCorrelationId( 1 ).build();
    input.send( message1 );
    Assert.assertNull( output.receive( 1000 ) );
    input.send( message2 );
    Assert.assertNull( output.receive( 1000 ) );

    context.close();

    context = new ClassPathXmlApplicationContext( "VoldemortMessageStoreAggregationTest-context.xml", getClass() );
    input = context.getBean( "inputChannel", MessageChannel.class );
    output = context.getBean( "outputChannel", QueueChannel.class );

    Message<?> message3 = MessageBuilder.withPayload( "3" )
                      .setSequenceNumber( 3 ).setSequenceSize( 3 ).setCorrelationId( 1 ).build();
    input.send( message3 );
    Assert.assertNotNull( output.receive( 1000 ) );

    context.close();
  }
View Full Code Here

    Object consumer = ac.getBean("smbOutboundChannelAdapter");
    assertTrue(consumer instanceof EventDrivenConsumer);
    Object messageSource = TestUtils.getPropertyValue(consumer, "handler");
    assertTrue(messageSource instanceof FileTransferringMessageHandler);

    MessageChannel smbChannel = ac.getBean("smbOutboundChannel", MessageChannel.class);

    for (int i = 0; i < fileNames.length; i++) {
      smbChannel.send(new GenericMessage<File>(new File(testLocalDir + fileNames[i])));
    }

    Thread.sleep(3000);

    // retrieve the session factory bean to check the test files are present in the remote location
View Full Code Here

        context.refresh();

        System.out.print("\nPlease enter the path to the file you want to upload: ");
        filePath = scanner.nextLine();

        final MessageChannel messageChannel = context.getBean("s3channel", MessageChannel.class);
        messageChannel.send(MessageBuilder.withPayload(new File(filePath)).build());

        break;

      }
      else if("2".equals(input.trim())) {
View Full Code Here

public class LbFailoverDemo {

  public static void main(String[] args) {
    ActiveMqTestUtils.prepare();
    ApplicationContext context = new ClassPathXmlApplicationContext("lb-config.xml", LbFailoverDemo.class);
    MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class);
    inputChannel.send(new GenericMessage<String>("A"));
    inputChannel.send(new GenericMessage<String>("B"));
    inputChannel.send(new GenericMessage<String>("C"));
  }
View Full Code Here

   * @param args
   */
  public static void main(String[] args) throws Exception {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("aggregator-config.xml", TimeBasedAggregationDemo.class);
   
    MessageChannel inChannel = context.getBean("inChannel", MessageChannel.class);
    Random random = new Random();
    while (true) {
      inChannel.send(MessageBuilder.withPayload("VMW").setHeader("price", 95 + random.nextDouble()).build());
      Thread.sleep(random.nextInt(687));
    }
  }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) throws Exception{
    ApplicationContext context = new ClassPathXmlApplicationContext("aggregator-config.xml", AggregatorDemo.class);
    MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class);
    int iterations = 13;
    for (int i = 0; i < iterations; i++) {
      Message<?> message = MessageBuilder.withPayload(i).setCorrelationId(1).
            setSequenceNumber(i).setSequenceSize(iterations).build();
      System.out.println("Sending: " + message);
      inputChannel.send(message);
     
      Thread.sleep(1000);
    }
  }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) throws Exception{
    ApplicationContext context = new ClassPathXmlApplicationContext("resequencer-config.xml", ResequencerDemo.class);
    MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class);
   
    inputChannel.send(MessageBuilder.withPayload(5).setCorrelationId(1).setSequenceNumber(5).build());
    inputChannel.send(MessageBuilder.withPayload(2).setCorrelationId(1).setSequenceNumber(2).build());
    inputChannel.send(MessageBuilder.withPayload(1).setCorrelationId(1).setSequenceNumber(1).build());
   
    inputChannel.send(MessageBuilder.withPayload(2).setCorrelationId(2).setSequenceNumber(2).build());
    inputChannel.send(MessageBuilder.withPayload(1).setCorrelationId(2).setSequenceNumber(1).build());
   
    inputChannel.send(MessageBuilder.withPayload(4).setCorrelationId(1).setSequenceNumber(4).build());
    inputChannel.send(MessageBuilder.withPayload(3).setCorrelationId(1).setSequenceNumber(3).build());
   
    inputChannel.send(MessageBuilder.withPayload(5).setCorrelationId(2).setSequenceNumber(5).build())
    inputChannel.send(MessageBuilder.withPayload(4).setCorrelationId(2).setSequenceNumber(4).build());
    inputChannel.send(MessageBuilder.withPayload(3).setCorrelationId(2).setSequenceNumber(3).build());
   
    System.in.read();
  }
View Full Code Here

public class GroovyControlBusDemo {

  public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("groovy-context.xml", GroovyControlBusDemo.class);
    NumberHolder numberHolder = context.getBean("numberHolder", NumberHolder.class);
    MessageChannel controlChannel = context.getBean("controlChannel", MessageChannel.class);
    System.out.println("number before increment: " + numberHolder.getNumber());
    Message<String> message = MessageBuilder.withPayload("numberHolder.increment()").build();
    controlChannel.send(message);
    System.out.println("number after increment:  " + numberHolder.getNumber());
    FilePoller filePoller = context.getBean("filePoller", FilePoller.class);
    System.out.println("file poller isRunning before start: " + filePoller.isRunning());
    controlChannel.send(MessageBuilder.withPayload("filePoller.start()").build());
    System.out.println("file poller isRunning after start:  " + filePoller.isRunning());
    controlChannel.send(MessageBuilder.withPayload("filePoller.stop()").build());
    System.out.println("file poller isRunning after stop:   " + filePoller.isRunning());
    ThreadPoolTaskExecutor executor = context.getBean("myExecutor", ThreadPoolTaskExecutor.class);
    System.out.println("max pool size before update: " + executor.getMaxPoolSize());
    controlChannel.send(MessageBuilder.withPayload("myExecutor.setMaxPoolSize(25)").build());
    System.out.println("max pool size after update:  " + executor.getMaxPoolSize());
  }
View Full Code Here

*/
public class GatewayDemo {

  public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("siia/jms/gateways.xml");
    MessageChannel toJMS = context.getBean("toJMS", MessageChannel.class);
    PollableChannel jmsReplies = context.getBean("jmsReplies", PollableChannel.class);
    MessagingTemplate template = new MessagingTemplate();
    template.convertAndSend(toJMS, "echo");
    Object response = template.receiveAndConvert(jmsReplies);
    System.out.println("response: " + response);
View Full Code Here

TOP

Related Classes of org.springframework.integration.MessageChannel

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.