+ All Categories
Home > Technology > ITEvent: JMS. Asynchronous communication in Java

ITEvent: JMS. Asynchronous communication in Java

Date post: 11-Nov-2014
Category:
Upload: -
View: 510 times
Download: 1 times
Share this document with a friend
Description:
 
Popular Tags:
38
JMS Asynchronous communication in Java Michał Szynkiewicz Examples: https://github.com/michalszynkiewicz/jms-examples Email: [email protected]
Transcript
Page 1: ITEvent: JMS. Asynchronous communication in Java

JMS

Asynchronous communication in Java

Michał Szynkiewicz

Examples: https://github.com/michalszynkiewicz/jms-examples

Email: [email protected]

Page 2: ITEvent: JMS. Asynchronous communication in Java

What's the point?Why do we need asynchronicity?

Page 3: ITEvent: JMS. Asynchronous communication in Java
Page 4: ITEvent: JMS. Asynchronous communication in Java

@POST public Response addCustomer(CustomerDto customer) {

validateCustomer(customer); storeCustomer(customer); return status(CREATED).build();

}

Page 5: ITEvent: JMS. Asynchronous communication in Java

@POST public Response addCustomer(CustomerDto customer) { validateCustomer(customer); storeCustomer(customer); sendConfirmationLink(customer.getEmail()); return status(CREATED).build(); }

Page 6: ITEvent: JMS. Asynchronous communication in Java
Page 7: ITEvent: JMS. Asynchronous communication in Java
Page 8: ITEvent: JMS. Asynchronous communication in Java
Page 9: ITEvent: JMS. Asynchronous communication in Java
Page 10: ITEvent: JMS. Asynchronous communication in Java
Page 11: ITEvent: JMS. Asynchronous communication in Java

Solution: send email asynchronously

Page 12: ITEvent: JMS. Asynchronous communication in Java

+ A standard+ Multiple implementations+ Loose coupling-/+ intermediary server- one way communication- Java API

What's JMS

Page 13: ITEvent: JMS. Asynchronous communication in Java

● Queue

● Topic

Communication schemes

Page 14: ITEvent: JMS. Asynchronous communication in Java

Queue

Page 15: ITEvent: JMS. Asynchronous communication in Java

Usage in our case

Page 16: ITEvent: JMS. Asynchronous communication in Java

Usage in our case

Page 17: ITEvent: JMS. Asynchronous communication in Java

Usage in our case

Page 18: ITEvent: JMS. Asynchronous communication in Java

● Queue

● Topic

Communication schemes

Page 19: ITEvent: JMS. Asynchronous communication in Java

Topic

Page 20: ITEvent: JMS. Asynchronous communication in Java

When to use topic?

Page 21: ITEvent: JMS. Asynchronous communication in Java

Topic use case: Error logging

Page 22: ITEvent: JMS. Asynchronous communication in Java

Topic use case: Error logging

Page 23: ITEvent: JMS. Asynchronous communication in Java

Topic use case: Error logging

Page 24: ITEvent: JMS. Asynchronous communication in Java

Topic use case: Error logging

Page 25: ITEvent: JMS. Asynchronous communication in Java

●Headers: ● e.g. JMSCorrelationID, JMSPriority

●Properties● application-specific headers

●Body● e.g. a String, Map, Object

Message

Page 26: ITEvent: JMS. Asynchronous communication in Java

● Choosing a subset of all messages● SQL-like syntax● Can only use properties and headers

E.g. “JMSPriority = 6 and myProperty='someValue'”

Message selectors

Page 27: ITEvent: JMS. Asynchronous communication in Java

Message selectors

Page 28: ITEvent: JMS. Asynchronous communication in Java

Reliability

Page 29: ITEvent: JMS. Asynchronous communication in Java

Message acknowledgement

● Message are kept on server until message acknowledgment comes ●Acknowledgement modes:

● AUTO — automatic● CLIENT — manual (message.acknowledge())● DUPS_OK — batch, may result in duplicates

Page 30: ITEvent: JMS. Asynchronous communication in Java

● Messages that failed to be processed, can be redelivered● Can be immediate or delayed● After maximum number of redeliveries message ends up in DLQ

Message redelivery

Page 31: ITEvent: JMS. Asynchronous communication in Java

Message persistence

● When JMS server goes down — messages are still kept ● May be disabled

Page 32: ITEvent: JMS. Asynchronous communication in Java

Common issue: Request-response

Page 33: ITEvent: JMS. Asynchronous communication in Java

On specJMS test it was able to handle 8M per second.

It uses disk storage for persistence.

Source: http://planet.jboss.org/post/8_2_million_messages_second_with_specjms

How fast can it be?On example of HornetQ

Page 34: ITEvent: JMS. Asynchronous communication in Java

Available at github: https://github.com/michalszynkiewicz/jms-examples

Spring code examples

Page 35: ITEvent: JMS. Asynchronous communication in Java

Not much :)

● Simplified API● Asynchronous sending (your code doesn't have to wait for JMS provider)● Delivery delay

What's new in JMS 2.0

Page 36: ITEvent: JMS. Asynchronous communication in Java

●AMQP+ cross-platform, full-feature, widely used- protocol still evolving, not backward compatible. Only few providers implement current version.

●STOMP+ via HTTP, widely implemented, lightweight- protocol doesn't describe destination types, etc

●MQTT+ extremely lightweight, used on mobile devices- no queue (topic only), no message properties (only

headers)

(Some) other messaging standards

Page 37: ITEvent: JMS. Asynchronous communication in Java

Questions?

Page 38: ITEvent: JMS. Asynchronous communication in Java

Дякую

email:[email protected]


Recommended