ythy / blog

Give everything a shot
6 stars 0 forks source link

JMS #324

Open ythy opened 4 years ago

ythy commented 4 years ago

API jms

Architecture

A JMS application is composed of the following parts:

Message Delivery Models

JMS supports two different message delivery models:

ythy commented 4 years ago

doSendAndReceive

/**
 * Send a request message to the given {@link Destination} and block until
 * a reply has been received on a temporary queue created on-the-fly.
 * <p>Return the response message or {@code null} if no message has
 * @throws JMSException if thrown by JMS API methods
 */
ythy commented 4 years ago

Two beans that you don’t see defined are JmsTemplate and ConnectionFactory. These are created automatically by Spring Boot. In this case, the ActiveMQ broker runs embedded.

2020-06-12 14:43:57.578  INFO 16856 --- [  restartedMain] o.apache.activemq.broker.BrokerService   : Apache ActiveMQ 5.15.6 (localhost, ID:IT-Maoxin-61635-1591944237436-0:1) is starting
2020-06-12 14:43:57.583  INFO 16856 --- [  restartedMain] o.apache.activemq.broker.BrokerService   : Apache ActiveMQ 5.15.6 (localhost, ID:IT-Maoxin-61635-1591944237436-0:1) started
2020-06-12 14:43:57.583  INFO 16856 --- [  restartedMain] o.apache.activemq.broker.BrokerService   : For help or more information please see: http://activemq.apache.org
2020-06-12 14:43:57.617  INFO 16856 --- [  restartedMain] o.a.activemq.broker.TransportConnector   : Connector vm://localhost started
ythy commented 4 years ago

Instances of the JmsTemplate class are thread-safe, once configured. This is important, because it means that you can configure a single instance of a JmsTemplate and then safely inject this shared reference into multiple collaborators.