- Why Java class don't inherit annotation: https://stackoverflow.com/a/4745820
H2 console website: http://localhost:8080/h2-console
- EntityManager belong to javax.persistence (now is jakarta.persistence)
- Hibernate has a interface call JPARepository which extends CRUDRepository and integrate EntityManager. You can check the source code
- FetchType 係請緊拎entity時LAZY拎埋入面嘅entity 定 eager一早拎埋. 唔關join 唔join 時
- FetchMode 係講緊拎個時用JOIN, SELECT定點拎
- FetchMode.JOIN will be ignored when using EntityManager.createQuery() except you use EntityManager CriteriaBuilder. https://stackoverflow.com/questions/18891789/fetchmode-join-makes-no-difference-for-manytomany-relations-in-spring-jpa-reposi
- GenerationType (IDENTITY, SEQUENCE, TABLE): https://www.hxstrive.com/subject/open_jpa/533.htm
- @IdClass for composite primary key
- Relationship: check BookEntity and https://blog.csdn.net/Xu_JL1997/article/details/103018249
- CascadeType https://blog.csdn.net/qq_43290288/article/details/105666055
- Join and Fetch in Specification: check BookService.getBooks
- Basic: https://kucw.github.io/blog/2020/11/rabbitmq/
- Priority Queue: https://medium.com/willhanchen/rabbitmq-%E8%A8%8A%E6%81%AF%E7%9A%84%E5%A6%82%E4%BD%95%E6%8F%92%E9%9A%8A-priority-ee7c9566b388
- Simple (Only one consumer)
2. Worker (Multiple consumer)
- Fan-out (type = fanout) (Message throw to all queue)
2. Routing (type = direct) (當 Producer 把 message 丟給 Exchange 時,同時要在這個 message 上面帶上一個 routing key,而 Exchange 就會根據這個 routing key,將 message 丟到指定的 Queue 上)
3. Topic (type = topic) (Similar to Direct, but it can use wildcard)
https://www.tpisoftware.com/tpu/articleDetails/2518
https://www.1ju.org/kafka/apache-kafka-fundamentals
Refer to kafka-docker
- Broker: Kafka server
- Cluster: A set of brokers
- Topic: Similar to RabbitMQ routing key
- Partition: Each topic contain 1 to many partition. New message append 平分 in one of partition. Partition store in one of distributed brokers
- Replica: If partition = 3, replica = 3, then each partition will have 3 replica. Total = 9 replica
- Leader: Each partition will have one broker as a leader node, other broker as a follower. If leader node crash, other follower will become as a leader.
- Retention: can define data retention policy
- Producer send message with topic to broker.
- Send message with key => same key will hash to same partition
- Without key => 轮询的方式 assign to partition
- Broker assign message in one of partition.
- Consumer subscribe topic by group id.
- Each partition only max 1 consumer with same group id to process
- Partition limit how many consumer process at the same time
- If number of partition is larger than number of consumer, some consumer will also consume no one handle partition.
- If group id is different, consumer groups will process message at the same time. Like fanout design
- If message is processed by consumer, consumer will fire acknowledged to broker.
- Broker update offset in ZooKeeper