Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Java EE 8 Design Patterns and Best Practices

You're reading from   Java EE 8 Design Patterns and Best Practices Build enterprise-ready scalable applications with architectural design patterns

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781788830621
Length 314 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
 Alberto Simoes Alberto Simoes
Author Profile Icon Alberto Simoes
Alberto Simoes
 Rocha Rocha
Author Profile Icon Rocha
Rocha
 Purificação Purificação
Author Profile Icon Purificação
Purificação
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
1. Introduction to Design Patterns FREE CHAPTER 2. Presentation Patterns 3. Business Patterns 4. Integration Patterns 5. Aspect-Oriented Programming and Design Patterns 6. Reactive Patterns 7. Microservice Patterns 8. Cloud-Native Application Patterns 9. Security Patterns 10. Deployment Patterns 11. Operational Patterns 12. MicroProfile 1. Other Books You May Enjoy Index

Implementing the service-activator pattern


We are now going to show code examples of the three solutions offered by the Java EE platform.

Implementing sending and receiving messages with JMS

The following is an example of a JMS message sender. This is a CDI bean that is responsible for sending messages:

public class MessageSender {
   @Inject
   @JMSConnectionFactory("jms/connectionFactory")
   JMSContext context;

   @Resource(mappedName = "jms/myQueue")
   Destination queue;

   public void sendSomeMessage (String message) {
      context.createProducer().send(queue, message);
   }
}

The @JMSConnectionFactory annotation indicates which ConnectionFactory should be used to create the JMSContext. The following code block shows an MDB that receives the message generated by the producer described earlier:

@MessageDriven(
 activationConfig = { @ActivationConfigProperty(
 propertyName = "destinationType", propertyValue = "javax.jms.Queue")
 })
public class EmailService implements MessageListener ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime
Visually different images