JMS message service introduction and usage scenarios
-
What is JMS: Java Message Service (Java Message Service), the interface for message-oriented middleware in the Java platform
-
JMS is a vendor-independent API used to access messaging system messages, similar to JDBC (Java Database Connectivity). Here, JDBC is an API that can be used to access many different relational databases
-
scenes to be used:
-
Core application
- Decoupling: Order System-"Logistics System
- Asynchronous: user registration-"send email, initialize information
- Peak clipping: spike, log processing
-
Cross-platform, multi-language
-
Distributed transaction, eventual consistency
-
RPC calls upstream and downstream docking, data source changes -> inform subordinates
-
Common concepts and programming models of message middleware
-
Common concepts
- JMS provider: connection of message-oriented middleware, an implementation of JMS interface, RocketMQ, ActiveMQ, Kafka, etc.
- JMS producer (Message Producer): a service that produces messages
- JMS Consumer (Message Consumer): Service for consuming messages
- JMS message: data object
- JMS queue: the area to store messages to be consumed
- JMS topic: a mechanism that supports sending messages to multiple subscribers
- There are usually two types of JMS messages: Point-to-Point, Publish/Subscribe
-
Basic programming model
- Some classes needed in MQ
- ConnectionFactory: connection factory, JMS uses it to create connections
- Connection: JMS client to JMS Provider connection
- Session: A thread that sends or receives messages
- Destination: The destination of the message; to whom the message is sent.
- MessageConsumer / MessageProducer: message consumer, message producer