Message-driven Bean)

Source: Internet
Author: User

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)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.