-
Notifications
You must be signed in to change notification settings - Fork 624
/
Copy pathDemoApplication.java
47 lines (40 loc) · 1.54 KB
/
DemoApplication.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package io.spring.cloudevent;
import java.net.URI;
import java.util.function.Function;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.function.cloudevent.CloudEventHeaderEnricher;
import org.springframework.cloud.function.cloudevent.CloudEventMessageBuilder;
import org.springframework.cloud.function.cloudevent.CloudEventMessageUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(DemoApplication.class, args);
}
@Bean
public Function<Person, Employee> hire() {
return person -> {
Employee employee = new Employee(person);
return employee;
};
}
// uncomment while keeping the above POJO function
// @Bean
// public CloudEventHeaderEnricher cloudEventEnricher() {
// return messageBuilder -> messageBuilder.setSource("http://spring.io/cloudevent")
// .setType("sample").setId("987654");
// }
// uncomment while commenting the previous two beans
// @Bean
// public Function<Message<Person>, Message<Employee>> hire() {
// return message -> {
// Person person = message.getPayload();
// Employee employee = new Employee(person);
// return CloudEventMessageBuilder.withData(employee).setId("123456")
// .setSource(URI.create("https://spring.cloudevenets.sample")).build();
// };
// }
}