Definition:A message driver is a component used to process message requests.
Message model:Point-to-Point message transmission and publishing/subscription message transmission
Point-to-Point message transmission model: One message can only be passed to one queue receiver.
Publish/subscribe message transmission:A message can be received by multiple recipients.
Detailed analysis:First, it is stateless.Session BeanWhen the client calls mdb, it can return immediately without waiting. mdb processes client requests asynchronously. mdb must implementMessagelistenerInterface. When the container detects a queue, it callsOnmessage ()Method.
Applicability:MDB is applicable when a business is executed for a long time and no real-time feedback of results is required. For example, if the order is successful, a successful text message or email is sent to the customer.
Queue message: (PTP message transmission model) Message-driven attributes can be described through annotations:
@ Messagedriven(Activationconfig=
{
@ Activationconfigproperty(Propertyname="Destinationtype",
Propertyvalue="Javax. JMS. Queue"),
@ Activationconfigproperty(Propertyname="Destination",
Propertyvalue="Queue/fashanshop"),
})
Details:@ MessagedrivenIndicates that this is a message-driven,@ ActivationconfigpropertyComment out various attributes of configuration information,DestinationtypeThe specified message type isQueueQueue,DestinationSpecifies the message path. Once the queue reaches the specified pathOnmessageMethod. The message is passed in as a parameter.
Certificate ----------------------------------------------------------------------------------------------------------------------------------------------------------------
Topic message: (pub/sub message transmission model) Message-driven attributes can be described through annotations:
@ Messagedriven(Activationconfig=
{
@ Activationconfigproperty(Propertyname="Destinationtype",
Propertyvalue="Javax. JMS. Topic"),
@ Activationconfigproperty(Propertyname="Destination",
Propertyvalue="Top/student"),
})
Details:@ MessagedrivenIndicates that this is a message-driven,@ ActivationconfigpropertyComment out various attributes of configuration information,DestinationtypeSpecify the message type as topic queue,DestinationSpecifies the message path. Once the queue reaches the specified pathOnmessageMethod. The message is passed in as a parameter.
Summary:
- Find the JMS provider (find the factory)
- Create a JMS connection)
- Create a jms session (create a Session Object)
- Find a JMS destination (use JNDI to find a JMS destination)
- Create a JMS producer or consumer (with session and destination objects, the consumer can obtain messages)
- Send or receive messages (build messages, send by producer, receive by consumer)