编程模型从命令式升级为函数式
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user