13 - jms. asynchronous communication in java - michal szynkiewicz - it event 2013 (5)

786 views

Published on

13 - JMS. Asynchronous communication in Java - Michal Szynkiewicz - IT Event 2013 (5)

This talk will give an introduction to Java Message Service. It will describe communication schemes supported by the JMS, give examples of JMS use cases, show how to use JMS with Spring Framework.
It will mention key features incoming in JMS 2.0 and give a brief overview of some alternatives to JMS protocol.

Michał Szynkiewicz
http://itevent.if.ua/lecture/jms-asynchronous-communication-java

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

13 - jms. asynchronous communication in java - michal szynkiewicz - it event 2013 (5)

  1. 1. JMSAsynchronous communication in JavaMichał SzynkiewiczExamples: https://github.com/michalszynkiewicz/jms-examplesEmail: michal.l.szynkiewicz@gmail.com
  2. 2. Whats the point?Why do we need asynchronicity?
  3. 3. @POSTpublic Response addCustomer(CustomerDto customer) {validateCustomer(customer);storeCustomer(customer);return status(CREATED).build();}
  4. 4. @POSTpublic Response addCustomer(CustomerDto customer) {validateCustomer(customer);storeCustomer(customer);sendConfirmationLink(customer.getEmail());return status(CREATED).build();}
  5. 5. Solution: send emailasynchronously
  6. 6. + A standard+ Multiple implementations+ Loose coupling-/+ intermediary server- one way communication- Java APIWhats JMS
  7. 7. ● Queue● TopicCommunication schemes
  8. 8. Queue
  9. 9. Usage in our case
  10. 10. Usage in our case
  11. 11. Usage in our case
  12. 12. ● Queue● TopicCommunication schemes
  13. 13. Topic
  14. 14. When to use topic?
  15. 15. Topic use case: Error logging
  16. 16. Topic use case: Error logging
  17. 17. Topic use case: Error logging
  18. 18. Topic use case: Error logging
  19. 19. ●Headers:● e.g. JMSCorrelationID, JMSPriority●Properties● application-specific headers●Body● e.g. a String, Map, ObjectMessage
  20. 20. ● Choosing a subset of all messages● SQL-like syntax● Can only use properties and headersE.g. “JMSPriority = 6 andmyProperty=someValue”Message selectors
  21. 21. Message selectors
  22. 22. Reliability
  23. 23. Message acknowledgement● Message are kept on server until messageacknowledgment comes●Acknowledgement modes:● AUTO — automatic● CLIENT — manual (message.acknowledge())● DUPS_OK — batch, may result in duplicates
  24. 24. ● Messages that failed to be processed, can beredelivered● Can be immediate or delayed● After maximum number of redeliveriesmessage ends up in DLQMessage redelivery
  25. 25. Message persistence● When JMS server goes down — messages arestill kept● May be disabled
  26. 26. Common issue: Request-response
  27. 27. On specJMS test it was able to handle 8M persecond.It uses disk storage for persistence.Source: http://planet.jboss.org/post/8_2_million_messages_second_with_specjmsHow fast can it be?On example of HornetQ
  28. 28. Available at github:https://github.com/michalszynkiewicz/jms-examplesSpring code examples
  29. 29. Not much :)● Simplified API● Asynchronous sending (your code doesnt haveto wait for JMS provider)● Delivery delayWhats new in JMS 2.0
  30. 30. ●AMQP+ cross-platform, full-feature, widely used- protocol still evolving, not backward compatible. Onlyfew providers implement current version.●STOMP+ via HTTP, widely implemented, lightweight- protocol doesnt describe destination types, etc●MQTT+ extremely lightweight, used on mobile devices- no queue (topic only), no message properties (onlyheaders)(Some) other messaging standards
  31. 31. Questions?
  32. 32. Дякуюemail:michal.l.szynkiewicz@gmail.com

×