编程模型从命令式升级为函数式

This commit is contained in:
2021-02-21 10:56:01 +08:00
parent 933b9db6fb
commit 1b8e541d68
12 changed files with 24 additions and 100 deletions

View File

@@ -1,10 +1,7 @@
package top.fjy8018.producer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.fjy8018.consumer.common.MySource;
@@ -16,15 +13,15 @@ import java.util.Date;
* @date 2018-10-08 17:57
*/
@RestController
@EnableBinding(MySource.class)
public class Producer {
@Autowired
private MySource channel;
private StreamBridge streamBridge;
@RequestMapping("/send")
public String send() {
channel.output().send(MessageBuilder.withPayload(new Date()).build());
streamBridge.send(MySource.OUTPUT, new Date());
return "success";
}
}

View File

@@ -1,8 +1,8 @@
spring:
rabbitmq:
host: 192.168.163.128
username: cms
password: cms-mq-admin
host: 192.168.133.128
username: dev-user
password: devpassword
cloud:
stream:
bindings:

View File

@@ -1,16 +0,0 @@
package top.fjy8018.producer.server;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ProducerServerApplicationTests {
@Test
public void contextLoads() {
}
}