ARTS是什么?
Algorithm:每周至少做一个LeetCode的算法题 Review:阅读并点评至少一篇英文文章 Tip:学习至少一个技术技巧 Share:分享一篇有观点和思考的技术文章
Algorithm
package leetcode;import java.util.HashMap;import java.util.Stack;/*** @className: LeetCode04* @description:* 给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效。* 有效字符串需满足:* 左括号必须用相同类型的右括号闭合。* 左括号必须以正确的顺序闭合。* 示例 1:* 输入:s = "()"* 输出:true** 示例 2:* 输入:s = "()[]{}"* 输出:true** 示例 3:* 输入:s = "(]"* 输出:false** 示例 4:* 输入:s = "([)]"* 输出:false* @author: Miluo* @date: 2021/3/14**/public class LeetCode04 {public boolean isValid(String s) {//奇数为falseif ((s.length() % 2) != 0){return false;}Stack<Character> stack = new Stack<>();HashMap<Character, Character> map = new HashMap<>();map.put(')','(');map.put('}','{');map.put(']','[');for (int i = 0; i < s.length(); i++) {if (map.containsKey(s.charAt(i))){if (stack.isEmpty()){return false;}if (map.get(s.charAt(i)) == stack.peek()){stack.pop();}else {return false;};}else {stack.push(s.charAt(i));}}return stack.isEmpty();}}
Review
Tools are not skills
从长远来看,知道why远比知道how更重要。像技术、框架、工具等会被淘汰,但是其核心思想、原理会延续。当有新事物出现时,有可能只是新瓶装旧酒,懂得其中根本,就能在短时间内上手。
Tip
Spring Cloud Stream
Spring Cloud Stream 在 Spring Cloud 体系内用于构建高度可扩展的基于事件驱动的微服务。
RocketMQ
//1.Maven依赖<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-stream-rocketmq</artifactId></dependency>//2.配置文件参考官方文档.Spring Cloud Stream 中的两个概念: Binder and Binding// Binder :用于与外部消息中间件集成的组件,用于创建绑定// Binding:充当消息中间件与应用程序的提供者和使用者之间的桥梁。开发人员只需要使用提供者或使// 用者来产生或使用数据,而不必担心与消息中间件的交互。//3.MessageChannelpublic interface DemoOutput(){//生产管道@Output(" *channel name* ")MessageChannel output();}public interface DemoInput(){//消费管道@Input(" *channel name* ")MessageChannel input();}//4.producer@Component@EnableBinding(DemoOutput.class)public class DemoProducer(){@Resuourceprivate DemoOutput demoOutputpublic void send(String message){Message<String> msg = MessageBuilder.WithPayload(message).build();//发送消息demoOutput.output().send(msg)}}//5.consumer@Component@EnableBinding(DemoInput.class)public class DemoProducer(){@StreamListener(" *channel name* ")public void consume(String message){...}}
