List of usage examples for org.springframework.messaging.support GenericMessage GenericMessage
public GenericMessage(T payload)
From source file:helloworld.HelloWorldApp.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("spring-integration-helloword-context.xml"); MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class); PollableChannel outputChannel = context.getBean("outputChannel", PollableChannel.class); inputChannel.send(new GenericMessage<String>("World")); System.out.println("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload()); }
From source file:org.s1p.app6.S1pKafkaApplication.java
public static void main(String[] args) throws Exception { ConfigurableApplicationContext context = new SpringApplicationBuilder(S1pKafkaApplication.class).web(false) .run(args);//ww w .ja va 2s .com TestBean testBean = context.getBean(TestBean.class); testBean.send(new GenericMessage<>(new Foo("foo", "bar"))); context.getBean(Listener.class).latch.await(60, TimeUnit.SECONDS); context.close(); }
From source file:com.st.si.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments/*from w w w . ja va 2s.c o m*/ */ public static void main(final String... args) { final AbstractApplicationContext context = new ClassPathXmlApplicationContext( "classpath:META-INF/spring/integration/*-context.xml"); context.registerShutdownHook(); DefaultSftpSessionFactory sftpSessionFactory = context.getBean(DefaultSftpSessionFactory.class); SftpSession session = sftpSessionFactory.getSession(); final DirectChannel requestChannel = (DirectChannel) context.getBean("inboundMGetRecursive"); //final PollableChannel replyChannel = (PollableChannel) context.getBean("output"); try { String dir = "/HVAC - Files For Testing/"; requestChannel.send(new GenericMessage<Object>(dir + "*")); /*if (!session.exists(sftpConfiguration.getOtherRemoteDirectory())) { throw new FileNotFoundException("Remote directory does not exists... Continuing"); }*/ rename(session, dir); dir = "/HPwES - Files For Testing/"; requestChannel.send(new GenericMessage<Object>(dir + "*")); rename(session, dir); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } /*final DirectChannel requestChannel = (DirectChannel) context.getBean("inboundMGetRecursive"); final PollableChannel replyChannel = (PollableChannel) context.getBean("output"); String dir = "/HVAC - Files For Testing/"; requestChannel.send(new GenericMessage<Object>(dir + "*")); Message<?> result = replyChannel.receive(1000); List<File> localFiles = (List<File>) result.getPayload(); for (File file : localFiles) { System.out.println(file.getName()); }*/ System.exit(0); }
From source file:com.wp.utils.kafka.KafkaProducer.java
public void produce(String message) throws Exception { messageChannel.send(new GenericMessage<>(message)); }
From source file:config.source.SourceModuleDefinition.java
@Bean @InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1")) public MessageSource<String> timerMessageSource() { return () -> new GenericMessage<>(new SimpleDateFormat(this.format).format(new Date())); }
From source file:com.springdeveloper.cloud.module.TimeSource.java
@Bean @InboundChannelAdapter(value = Source.OUTPUT, autoStartup = "false", poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1")) public MessageSource<String> timerMessageSource() { return () -> new GenericMessage<>(new SimpleDateFormat(this.options.getFormat()).format(new Date())); }
From source file:eric.bottard.tis100.SpringNode.java
@Override public ValueDestination destinationPort(String port) { switch (port) { case "UP": return (v) -> ports.outUp().send(new GenericMessage<>(v)); case "DOWN": return (v) -> ports.outDown().send(new GenericMessage<>(v)); case "LEFT": return (v) -> ports.outLeft().send(new GenericMessage<>(v)); case "RIGHT": return (v) -> ports.outRight().send(new GenericMessage<>(v)); default:/* w ww . j av a 2s . c o m*/ throw new IllegalStateException("Cannot write to port " + port); } }
From source file:io.spring.TaskProcessorApplicationTests.java
@Test public void test() throws InterruptedException, IOException { channels.input().send(new GenericMessage<Object>(DEFAULT_PAYLOAD)); Map<String, String> properties = new HashMap(); properties.put("payload", DEFAULT_PAYLOAD); TaskLaunchRequest expectedRequest = new TaskLaunchRequest( "maven://org.springframework.cloud.task.app:" + "timestamp-task:jar:1.0.1.RELEASE", null, properties, null, null);//from w ww . j a v a 2 s. c o m Message<String> result = (Message<String>) collector.forChannel(channels.output()).take(); TaskLaunchRequest tlq = mapper.readValue(result.getPayload(), TaskLaunchRequest.class); assertThat(tlq, is(expectedRequest)); }
From source file:cn.com.sina.alan.demo.SampleSource.java
@Bean @InboundChannelAdapter(value = Source.SAMPLE, poller = @Poller(fixedDelay = "1000", maxMessagesPerPoll = "1")) public MessageSource<String> timerMessageSource() { return new MessageSource<String>() { public Message<String> receive() { System.out.println("******************"); System.out.println("At the Source"); System.out.println("******************"); Converters.Foo foo = new Converters.Foo(); foo.setValue("hi"); System.out.println("Sending value: " + foo.getValue() + " of type " + foo.getClass()); return new GenericMessage(foo); }//from w w w.j a va2 s .c o m }; }
From source file:reactivity.Source.java
/** * Produces a random value.//from ww w . j av a2 s . c o m * * @return the random value to be processed */ @Bean @InboundChannelAdapter(value = Processor.INPUT, poller = @Poller(fixedDelay = "1000", maxMessagesPerPoll = "1")) public MessageSource<String> timerMessageSource() { return () -> new GenericMessage<>(UUID.randomUUID().toString().toLowerCase()); }