This document discusses event-driven architecture and how to implement it using Java technologies. It covers key concepts like events, loose coupling, message queues, publish-subscribe patterns, and using Java Message Service (JMS) for reliable messaging between distributed systems. Implementing event-driven architecture with events, messaging and loose coupling allows building scalable, high-performance applications.
Scalable Persistent Message Brokering with WSO2 Message BrokerSrinath Perera
A highly available and fast message broker ensures high-volume message delivery and supports reliable business operations. While most open source message broker projects don’t match commercial offerings, WSO2 Message Broker 2.0 offers broker domains, a distributed architecture, and extreme scalability. In this session, Srinath will describe the new distributed message broker architecture, message sharing across brokers via a Cassandra cluster, and an AMQP based JMS style API. He will discuss the WSO2 Message Broker 2.0 design and explore real world use cases.
Taking Your Enterprise to the Next Level with WSO2 Message Broker and WSO2 En...WSO2
In order to cater to the increased demand for reliable and flexible systems, enterprises are leveraging messaging as a solution. In the enterprise integration space, these solutions have evolved into well defined enterprise integration patterns (EIPs). WSO2 Enterprise Service Bus (WSO2 ESB) and WSO2 Message Broker can be used to implement these patterns with ease.
This webinar will discuss how to use WSO2 ESB and WSO2 Message Broker to address the aforementioned needs. The key areas of discussion will include how to
Achieve scalability using point-to-point, publisher/subscriber EIPs and shared subscriptions
Achieve reliability using transactions
Perform request throttling using the store/forward EIP
Integrate between devices in constrained environments (low-bandwidth, unreliable networks, etc.)
The 100% open source WSO2 Message Broker is a lightweight, easy-to-use, distributed message-brokering server. It features high availability (HA) support with a complete hot-to-hot continuous availability mode, the ability to scale up to several servers in a cluster, and no single point of failure. It is designed to manage persistent messaging and large numbers of queues, subscribers and messages.
Overview of Publish/Subscribe messaging and comparison of MQTT, AMQP and DDS protocols.
Presented in IoT Bratislava meeting
Recorded session (in Slovak): https://www.youtube.com/watch?v=7wqyriSAqLY
IBM MQ: Using Publish/Subscribe in an MQ NetworkDavid Ware
The publish/subscribe model can be used across a network of MQ queue managers, whether in a manually configured topology or in an MQ cluster. This session looks in-depth at designing such systems, covering a wide range of requirements from availability to scalability, and explaining how they can be addressed. A basic understanding of publish/subscribe in MQ would be beneficial for attendees.
For an introduction to MQ publish/subscribe, first see this presentation: http://www.slideshare.net/DavidWare1/ame-2271-mq-publish-subscribe-pdf
IBM MQ CONNAUTH/CHLAUTH Doesn't Work Like You Think it Does (and if you aren'...T.Rob Wyatt
Native MQ password authentication (CONNAUTH) introduced in IBM MQ v8.0 has gotten off to a rough start. As of Fix Pack 8.0.0.5, the interaction between CONNAUTH and CHLAUTH has exhibited 5 distinct behaviors. After applying Fix Packs some of these cause hard failures while others silently over-authorize client users, leaving the queue manager exposed. This webcast will present findings from our CONNAUTH/CHLAUTH security research as well as recommendations for MQ users and the audit community.
Scalable Persistent Message Brokering with WSO2 Message BrokerSrinath Perera
A highly available and fast message broker ensures high-volume message delivery and supports reliable business operations. While most open source message broker projects don’t match commercial offerings, WSO2 Message Broker 2.0 offers broker domains, a distributed architecture, and extreme scalability. In this session, Srinath will describe the new distributed message broker architecture, message sharing across brokers via a Cassandra cluster, and an AMQP based JMS style API. He will discuss the WSO2 Message Broker 2.0 design and explore real world use cases.
Taking Your Enterprise to the Next Level with WSO2 Message Broker and WSO2 En...WSO2
In order to cater to the increased demand for reliable and flexible systems, enterprises are leveraging messaging as a solution. In the enterprise integration space, these solutions have evolved into well defined enterprise integration patterns (EIPs). WSO2 Enterprise Service Bus (WSO2 ESB) and WSO2 Message Broker can be used to implement these patterns with ease.
This webinar will discuss how to use WSO2 ESB and WSO2 Message Broker to address the aforementioned needs. The key areas of discussion will include how to
Achieve scalability using point-to-point, publisher/subscriber EIPs and shared subscriptions
Achieve reliability using transactions
Perform request throttling using the store/forward EIP
Integrate between devices in constrained environments (low-bandwidth, unreliable networks, etc.)
The 100% open source WSO2 Message Broker is a lightweight, easy-to-use, distributed message-brokering server. It features high availability (HA) support with a complete hot-to-hot continuous availability mode, the ability to scale up to several servers in a cluster, and no single point of failure. It is designed to manage persistent messaging and large numbers of queues, subscribers and messages.
Overview of Publish/Subscribe messaging and comparison of MQTT, AMQP and DDS protocols.
Presented in IoT Bratislava meeting
Recorded session (in Slovak): https://www.youtube.com/watch?v=7wqyriSAqLY
IBM MQ: Using Publish/Subscribe in an MQ NetworkDavid Ware
The publish/subscribe model can be used across a network of MQ queue managers, whether in a manually configured topology or in an MQ cluster. This session looks in-depth at designing such systems, covering a wide range of requirements from availability to scalability, and explaining how they can be addressed. A basic understanding of publish/subscribe in MQ would be beneficial for attendees.
For an introduction to MQ publish/subscribe, first see this presentation: http://www.slideshare.net/DavidWare1/ame-2271-mq-publish-subscribe-pdf
IBM MQ CONNAUTH/CHLAUTH Doesn't Work Like You Think it Does (and if you aren'...T.Rob Wyatt
Native MQ password authentication (CONNAUTH) introduced in IBM MQ v8.0 has gotten off to a rough start. As of Fix Pack 8.0.0.5, the interaction between CONNAUTH and CHLAUTH has exhibited 5 distinct behaviors. After applying Fix Packs some of these cause hard failures while others silently over-authorize client users, leaving the queue manager exposed. This webcast will present findings from our CONNAUTH/CHLAUTH security research as well as recommendations for MQ users and the audit community.
Internet companies with huge traffic and millions of users have tasks involved that cannot be served in a request. RabbitMQ can process tasks or communication between different app components asynchronously but close to real time.
Secure Your Messages with IBM MQ Advanced Message SecurityMorag Hughson
In some scenarios, securing access to your messaging infrastructure is not enough. You must also secure access to message content. This session will cover how to provide end-to-end message protection where message contents are secure from the point they are sent to the point they are received, including while at rest in queues. Topics covered include: an overview of message level security, when it is appropriate to deploy this level of protection, how the message protection is applied,how it can be administered, and the new features available in the latest version of IBM MQ.
Reliable System Integration and Scaling with WSO2 Message BrokerWSO2
To view the recording of this webinar please use the below URL:
http://wso2.com/library/webinars/2016/03/reliable-system-integration-and-scaling-with-wso2-message-broker/
Messaging has been used widely by enterprise architects to reliably integrate and scale systems. Commonly used messaging patterns include distributed queues/topics and dead letter channels with varied quality of service levels. When adopting a message broker, architects not only need to look at features but also at the deployment and maintenance complexity, internal architecture and surrounding concepts.
This session will discuss the internal architecture of WSO2 Message Broker (WSO2 MB) 3.1 and focus on
Improved performance with optimized message dissemination model
Ease of use and reliability with a message persistence layer backed by RDBMS
Simplified deployment layout and less operational complexity with Hazelcast based clustering scheme
New features of WSO2 MB 3.1
In this JBug, Tom will use an example driven format to illustrate some of the new features that have been added into Narayana recently. We will look at:
1. Why you need a transaction manager - a brief revision course
2. Using Narayana inside none-EE containers, mainly focussing on Tomcat
Interconnect 2017: 6893 Keep out the bad guys by securing your MQ messaging e...Robert Parker
Presentation delivered at Interconnect 2017. Session ID 6893: Keep out the bad guys by securing your MQ messaging environment.
With today's focus on security, ensuring you utilize all of the options available to maximize your systems security is a high priority for many businesses. In this session, we will work through a step-by-step case study that details how you can enhance the security of your Queue Managers using the different features available in IBM MQ.
IBM MQ - better application performanceMarkTaylorIBM
Presented in Feb 2015 at Interconnect
This presentation is aimed at helping application developers understand how to best use MQ features for higher performance.
A peek into the middle of the enterprise software architecture stack.
A curtain raiser into the middleware of the software technology stack. Showcases Types of middleware, configuration possibilities, high level components, features, messaging models, deployment,
Internet companies with huge traffic and millions of users have tasks involved that cannot be served in a request. RabbitMQ can process tasks or communication between different app components asynchronously but close to real time.
Secure Your Messages with IBM MQ Advanced Message SecurityMorag Hughson
In some scenarios, securing access to your messaging infrastructure is not enough. You must also secure access to message content. This session will cover how to provide end-to-end message protection where message contents are secure from the point they are sent to the point they are received, including while at rest in queues. Topics covered include: an overview of message level security, when it is appropriate to deploy this level of protection, how the message protection is applied,how it can be administered, and the new features available in the latest version of IBM MQ.
Reliable System Integration and Scaling with WSO2 Message BrokerWSO2
To view the recording of this webinar please use the below URL:
http://wso2.com/library/webinars/2016/03/reliable-system-integration-and-scaling-with-wso2-message-broker/
Messaging has been used widely by enterprise architects to reliably integrate and scale systems. Commonly used messaging patterns include distributed queues/topics and dead letter channels with varied quality of service levels. When adopting a message broker, architects not only need to look at features but also at the deployment and maintenance complexity, internal architecture and surrounding concepts.
This session will discuss the internal architecture of WSO2 Message Broker (WSO2 MB) 3.1 and focus on
Improved performance with optimized message dissemination model
Ease of use and reliability with a message persistence layer backed by RDBMS
Simplified deployment layout and less operational complexity with Hazelcast based clustering scheme
New features of WSO2 MB 3.1
In this JBug, Tom will use an example driven format to illustrate some of the new features that have been added into Narayana recently. We will look at:
1. Why you need a transaction manager - a brief revision course
2. Using Narayana inside none-EE containers, mainly focussing on Tomcat
Interconnect 2017: 6893 Keep out the bad guys by securing your MQ messaging e...Robert Parker
Presentation delivered at Interconnect 2017. Session ID 6893: Keep out the bad guys by securing your MQ messaging environment.
With today's focus on security, ensuring you utilize all of the options available to maximize your systems security is a high priority for many businesses. In this session, we will work through a step-by-step case study that details how you can enhance the security of your Queue Managers using the different features available in IBM MQ.
IBM MQ - better application performanceMarkTaylorIBM
Presented in Feb 2015 at Interconnect
This presentation is aimed at helping application developers understand how to best use MQ features for higher performance.
A peek into the middle of the enterprise software architecture stack.
A curtain raiser into the middleware of the software technology stack. Showcases Types of middleware, configuration possibilities, high level components, features, messaging models, deployment,
Message Queuing (MSMQ) technology enables applications running at different times to communicate across heterogeneous networks and systems that may be temporarily offline.
The Overview of Microservices ArchitectureParia Heidari
After reading, you are able to answer the following questions.
Why migrating to Microservices?
What are the advantages and drawbacks of Monolithic Architecture?
What are the advantages and disadvantages of Microservices Architecture?
What is the process of messaging in Microservices?
What is the process of integrating microservices with Pub/Sub?
Reliable communication is essential for microservice based architectures. One of the most effective patterns for microservices communication is message queue. We'll see how a Rubyist can build scalable microservices using RabbitMQ and run it on the AWS infrastructure in Docker containers.
Beyond REST and RPC: Asynchronous Eventing and Messaging PatternsClemens Vasters
In this session you will learn about when and why to use asynchronous communication with and between services, what kind of eventing/messaging infrastructure you can use in the cloud and on the edge, and how to make it all work together.
This full detailed presentation on Enterprise message using JMS. This will provide details required from a junior programmer to architect level. Some of the information presented is inspired by some authors from various sources.
IBM IMPACT 2014 - AMC-1882 Building a Scalable & Continuously Available IBM M...Peter Broadhurst
An introduction to one possible MQ architecture - an active/active multiple queue manager client<->server environment.
Summary of detailed topology articles available here:
http://ow.ly/vrUUV
And MQDev blog+discussion on client attachment here:
http://ibm.co/MM8rMl
Software Engineering, Software Consulting, Tech Lead, Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Transaction, Spring MVC, OpenShift Cloud Platform, Kafka, REST, SOAP, LLD & HLD.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaYara Milbes
Discover the transformative power of the WhatsApp API in our latest SlideShare presentation, "Top 7 Unique WhatsApp API Benefits." In today's fast-paced digital era, effective communication is crucial for both personal and professional success. Whether you're a small business looking to enhance customer interactions or an individual seeking seamless communication with loved ones, the WhatsApp API offers robust capabilities that can significantly elevate your experience.
In this presentation, we delve into the top 7 distinctive benefits of the WhatsApp API, provided by the leading WhatsApp API service provider in Saudi Arabia. Learn how to streamline customer support, automate notifications, leverage rich media messaging, run scalable marketing campaigns, integrate secure payments, synchronize with CRM systems, and ensure enhanced security and privacy.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeAftab Hussain
Understanding variable roles in code has been found to be helpful by students
in learning programming -- could variable roles help deep neural models in
performing coding tasks? We do an exploratory study.
- These are slides of the talk given at InteNSE'23: The 1st International Workshop on Interpretability and Robustness in Neural Software Engineering, co-located with the 45th International Conference on Software Engineering, ICSE 2023, Melbourne Australia
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
2. www.luxoft.com
Event-Driven Architecture with Java Technology Stack
1. Event-Driven Architecture
2. Using Events in Java EE CDI Applications
3. Message-Oriented Middleware
4. Java Message Service
5. Message Queue and Publish-Subscribe Patterns
6. Reliable Message Delivery
7. Message Priority and Scheduled Delivery
8. Distributed Transactions
3. www.luxoft.com
Why Do We Need Event-Driven Architecture?
Let’s consider checkout shopping cart functionality for e-commerce framework.
public void checkoutShoppingCart(ShoppingOrder order) {
persistInDatabase(order);
sendEmailNotification(order);
shipToTheNearestWarehouse(order);
scheduleShippingToCustomer(order);
exportToERP(order);
}
Method checkoutShoppingCart becomes unmaintainable mess.
4. www.luxoft.com
Why Do We Need Event-Driven Architecture?
• The growing complexity of enterprise applications often result in bad
architecture, and organization is spending more and more money
building IT systems;
• Event-driven architecture is designed to solve these problems by
decoupling software components and services.
5. www.luxoft.com
Why Do We Need Event-Driven Architecture?
The goal of event-driven architecture is to allow to loosely couple
system components together.
6. www.luxoft.com
What Is Event?
• Event is a significant change in state;
• Events are transmitted among loosely coupled services;
• Events represent milestones in business process;
• Services observe events and react on them.
7. www.luxoft.com
Observer Pattern
• Observer pattern helps to understand event-driven architecture concepts;
• In observer pattern an object, called the subject, maintains a list of its dependents, called
observers, and notifies them of any state changes;
• Making use of events and observers makes services even more loosely coupled.
8. www.luxoft.com
Loose Coupling
• Components are loosely coupled if they have little or no direct knowledge
of each other;
• Coupling refers to classes, interfaces, services, software components;
• When a dependent class contains a pointer directly to a concrete class
which provides the required behavior, they are tightly coupled;
• When events and observers are used, class firing the event has no
knowledge of class observing and reacting on this event.
9. www.luxoft.com
Performance
• Designing systems to be asynchronous from end-to-end allows to
minimize the amount of threads blocking on IO operations, and to
use network bandwidth to its full capacity;
• All observers will react in parallel on notification about event,
making multi-core CPUs and clusters work on its highest capacity;
• When distributed system runs in cluster, events can be delivered to
any host of the cluster providing transparent load-balancing and
failover.
11. www.luxoft.com
Using Events in Java EE CDI Applications
ShoppingOrderEvent bean defines an event using properties, which
has setter and getter methods.
private ShoppingOrder order;
...
public ShoppingOrderEvent() {
}
12. www.luxoft.com
Using Events in Java EE CDI Applications
Events are handled using an observer method.
public void persistInDatabase(@Observes ShoppingOrderEvent event) {
...
}
public void sendEmailNotification(@Observes ShoppingOrderEvent event) {
...
}
public void shipToTheNearestWarehouse(@Observes ShoppingOrderEvent event) {
...
}
public void scheduleShippingToCustomer(@Observes ShoppingOrderEvent event) {
...
}
public void exportToERP(@Observes ShoppingOrderEvent event) {
...
}
13. www.luxoft.com
Using Events in Java EE CDI Applications
To fire an event and notify any observer method, call the
javax.enterprise.event.Event.fire method.
@Inject
private Event<ShoppingOrderEvent> orderEvent;
public void checkoutShoppingCart(ShoppingOrder order) {
ShoppingOrderEvent orderEventPayload =
new ShoppingOrderEvent();
...
orderEvent.fire(orderEventPayload);
}
14. www.luxoft.com
Using Events in Java EE CDI Applications
• Each observer method as well as method firing event can be located
in different classes and packages;
• The senders and consumers of messages are completely
independent and know nothing of each other;
• Maximum loose coupling is achieved.
15. www.luxoft.com
Message-Oriented Middleware
• Events can be presented as messages;
• Message-oriented middleware (MOM) is software supporting sending
and receiving messages between distributed systems;
• MOM is sometimes called messaging system or message broker and
is an extra component in the architecture.
16. www.luxoft.com
Message-Oriented Middleware
Messaging systems usually provide protocol or API for sending and
receiving messages:
• JMS - Java Message Service
• AMQP - Advanced Message Queuing Protocol
• STOMP - Simple Text Oriented Messaging Protocol
• RESTful API
• System specific APIs
18. www.luxoft.com
Java Message Service
• Java Message Service (JMS) is a standard of middleware for
sending messages, that allows applications, running on Java EE
platform, to create, send, receive and read messages;
• JMS is a Java API, part of Java EE specification.
19. www.luxoft.com
JMS 2.0 Example
Sending messages using JMS.
@Resource(mappedName =
"java:jboss/jms/queue/exampleQueue")
private Queue exampleQueue;
@Inject
private JMSContext context;
...
public void sendMessage(String text) {
context.createProducer().send(exampleQueue, text);
}
20. www.luxoft.com
JMS 2.0 Example
Synchronous receiving messages using JMS.
@Resource(mappedName =
"java:jboss/jms/queue/exampleQueue")
private Queue exampleQueue;
@Inject
private JMSContext context;
...
public String receiveMessage() {
return context.createConsumer(exampleQueue)
.receiveBody(String.class);
}
21. www.luxoft.com
Message-Driven Bean Example
Receiving messages with message-driven bean (MDB) an EJB that allows Java EE applications to process messages asynchronously.
@MessageDriven(name = "ExampleMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationLookup",
propertyValue = "java:jboss/jms/queue/exampleQueue"),
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode",
propertyValue = "Auto-acknowledge")})
public class ExampleMDB implements MessageListener {
public void onMessage(Message message) {
try {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
...
}
} catch (JMSException e) {
throw new RuntimeException(e);
}
}
}
22. www.luxoft.com
Message Queue Pattern
1. Message is sent to queue;
2. Message is persisted to provide a guarantee of delivery;
3. Messaging system delivers the message to a consumer;
4. Consumer processes and acknowledges the message;
5. Message is removed from the queue and is not available to be delivered
again;
6. If the system crashes before the messaging server receives an
acknowledgement from the consumer, then on recovery, the message will
be delivered to a consumer again.
23. www.luxoft.com
Publish-Subscribe Pattern
• Message is sent to topic;
• Each subscription receives a copy of each message sent to the
topic;
• Durable subscriptions receives all messages sent to the topic even
if consumer was not available for some time;
• Non durable subscriptions receives only those messages, that were
sent while consumer was available.
24. www.luxoft.com
Reliable Message Delivery
Message delivery occurs in two hops:
• the first hop takes the message from the producer to a physical
destination on the broker
• the second hop takes the message from that destination to the
consumer
25. www.luxoft.com
Reliable Message Delivery
A message can be lost in one of three ways:
• on its hop from the producer to the broker
• on its hop from the broker to the consumer
• while it’s in broker memory (if the broker fails)
Reliable delivery guarantees that delivery will not fail in any of these
ways.
26. www.luxoft.com
Reliable Message Delivery
Two mechanisms are used to ensure reliable delivery:
• acknowledgments or transactions are used to make sure
message was successfully consumed
• messaging system stores messages in a persistent store called
journal so that if the broker fails before the message is consumed,
the stored copy of the message can be redelivered on recovery
27. www.luxoft.com
Reliable Message Delivery
Messages are either durable or non-durable.
• Durable messages will be persisted in permanent storage and will
survive server failure or restart;
• Non durable messages will not survive server failure or restart.
29. www.luxoft.com
Message Redelivery
• To prevent clogging the system with messages that are delivered
again and again without success, messaging systems define dead
letter concept;
• After a specified unsuccessful delivery attempts, the message is
removed from the destination and put instead in a dead letter
queue.
30. www.luxoft.com
Message Redelivery
• Messaging systems also defines delayed redelivery concept;
• Redelivery will be scheduled with a delay;
• Delay between delivery attempts can increase exponentially.
31. www.luxoft.com
Message Expiration
• The time messages are retained in messaging system before it will
be removed can be limited;
• JMS providers set JMSExpiration field when a message is sent;
• When messages are expired, they are removed from the queue and
sent to the expiry queue.
32. www.luxoft.com
Message Priority
• By default messaging system queues operates as FIFO queues;
• Explicitly specifying message priority will make messaging queue operate
as priority queue;
• Message priority can be used to influence the delivery order for
messages;
• The message priority value is of type integer, ranging from 0 (the lowest) to
9 (the highest);
• Messages of higher priorities will likely be delivered before those of lower
priorities.
33. www.luxoft.com
Message Priority
• If business process can be decomposed into set of tasks
or activities, message priority can be used to interrupt
low priority business processes if higher priority business
process was started;
• High priority requests will be processed as fast as possible
and low priority requests will be processed when there will
be free computing resources.
34. www.luxoft.com
Message Priority
1. Send message with appropriate priority to the queue to start business
process;
2. Service consuming the message should perform corresponding activity and
at the end send another message into the queue propagating initial priority
to proceed business process;
3. If there are messages with higher priorities in the queue and there are not
enough computing resources, messages with higher priorities will be
processed first and after that messages with lower priority;
4. Business process with lower priority will be “interrupted” to let higher priority
business process complete.
35. www.luxoft.com
Scheduled Delivery
Most messaging systems provide a way to schedule message delivery.
This feature will be useful when:
• Business process should not be started immediately after message
was sent;
• Business process should be cancelled after some timeout.
36. www.luxoft.com
Scheduled Delivery
HornetQ example of scheduled delivery.
...
TextMessage message = session.createTextMessage(
"This is a scheduled message message which will be delivered in 5 sec.");
message.setLongProperty("_HQ_SCHED_DELIVERY", System.currentTimeMillis() + 5000);
producer.send(message);
...
// message will not be received immediately but 5 seconds later
TextMessage messageReceived = (TextMessage) consumer.receive();
...
37. www.luxoft.com
Distributed Transactions
• The JMS specification supports distributed transactions;
• The production and consumption of messages can be part of a
larger, distributed transaction that includes operations involving
other resource managers, such as database systems;
• A distributed transaction manager, like the one supplied by the
application server, must be available to support distributed
transactions.
38. www.luxoft.com
Two-Phase Commit
• Distributed transactions with two-phase commit (2PC) are also
called XA transactions;
• Support for distributed transactions means that messaging clients
can participate in distributed transactions through the XAResource
interface defined by JTA;
• This interface defines a number of methods used in implementing
two-phase commit.
39. www.luxoft.com
Two-Phase Commit
• Phase 1 - Prepare. Transaction coordinator, asks participating resources to
promise to commit or rollback the transaction. If any resource cannot
prepare, the transaction is rolled back;
• Phase 2 - Commit or Rollback. If all participants respond to the
coordinator that they are prepared, then the coordinator asks all resources
to commit the transaction.
2PC is done automatically by transaction manager (typically a part of Java EE
application server) and requires no actions from developer.
40. www.luxoft.com
Best Effort One-Phase Commit
The best efforts 1PC pattern is synchronized single-phase commit of a number of
resources.
The message transaction is started before the database one, and they end (either commit or
rollback) in reverse order.
1. Start messaging transaction
2. Receive message
3. Start database transaction
4. Update database
5. Commit database transaction
6. Commit messaging transaction
41. www.luxoft.com
Best Effort One-Phase Commit
• If the commit of the database resource fails, messaging transaction
will be rolled back;
• If the commit of the database resource success but the commit of
the messaging transaction fails, it will result in duplicate message
(message will be redelivered);
• Best effort 1PC commit can be used if system is able to
appropriately handle duplicate messages.
42. www.luxoft.com
Best Effort One-Phase Commit
Best effort 1PC example in Spring.
<bean id="nonTransactionalConnectionFactory"
class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory" ref="hornetQConnectionFactory"/>
<property name="username" value="guest"/>
<property name="password" value="guest"/>
</bean>
<bean id="connectionFactory"
class="org.springframework.jms.connection.TransactionAwareConnectionFactoryProxy">
<property name="targetConnectionFactory"
ref="nonTransactionalConnectionFactory"/>
<property name="synchedLocalTransactionAllowed" value="true"/>
</bean>
...
45. www.luxoft.com
Transactions and Redelivery
• It is a common practice to rely on message redelivery in case of
distributed transaction failure;
• If it is acceptable for business process to be repeated, exception
handling in code can be skipped;
• Whole distributed transaction can be rolled back, message will be
returned to queue and delivered to available consumer to be
processed again.