Please enable JavaScript.
Coggle requires JavaScript to display documents.
JMS (Design JMS solution for production (Synchronous Messaging (UseCase:-…
JMS
Design JMS solution for production
Error & Exception Handling
UseCase :Automatic Reconnection
setExceptionLisitiner
override ExceptionListener's onExcpetion message
Message Selectors
Consume message based on property Evlauation
set messageSelector in CreateConsumer signature
Messaging Ordering
JMS mulitple consumer doesn't allow message recieved in order
Competing consumer in defaultMessageLisitnerContainer Impl
Ordering matters eg :- customer creation vs update.
Best: Code should deal
place unexpected message back to queue or in new queue
message priority
JMSXGroupID
pros
Guarantees order based on this property
still allow failover should consumer "die"
cons
only 1 consumer per JMSXGroupID property
effects throughput
Synchronous Messaging
UseCase:- Rendering web page
Create a reply message
set reply message's JMSCorrelationID to request.JMSMessageID
High Availability and Throughput
Consider JMS provider that has
Good HA Architecure
Clustered
Reliable and Fast Failover
Examples
Override a MessageLisitner's Onmessage() and set the delay.
Assume, 200 ms for delay and processing 100 message = 20sec to process
Improve by starting more consumers by running mulitple instances
It provides additional throughput and also higly available solution
Create Mulitple Consumers per JVM
In for log create consumer and store in list
Advised to use defaultMessageListinerContainer
Resource Caching
Dynamic Multiple Consumers
Automatic Reconnection
Dead Letter Queues
Good JMS broker will have MessageRedilivery and DLQ
Redelivery to broker is responsibility of application
Controlled at connenctionFactory's Redilevery Policy
Efficient Use of Resources
Cache connectionfactory,connection,session,producerMessage
Basic JMS use Case
Sessions
CLIENT_ACKNOWLEDGE
DUPS_OK_ACKNOWLEDGE
AUTO_ACKNOWLEDGE(is marked delivered and is not eligible to be delivered again)
Sending Messages
Connections
Consuming Messages
Connection factories
Should we be using JMS ?
pros
APIs are Stable
Moving between implementation is relatively easy
Really mature
Many providers/implentations
lots of documentation
Most JMS implementations offer excellent features
Implementation to meet varying budgets
Cons
API can be clunky sometimes
JMS 2.0 has simplified APIs
frameworks/Patterns mitigate this
JMS is a specification
Interoperability depends on the message broker
solution :- use AMQP- Advanced message queuing protocol
Not interoperable with other non-JVM languages(and some on the JVM)
Benefits
loosely coupled application