Powered By Blogger

Friday, September 6, 2013

Weblogic JMS Message Throttling

In this post, we will see how can we setup weblogic JMS message throttling.
There are three possible setups to implement this feature
  1. Flow control (used for message producer)
  2. JCA property(used for message consumer)
  3. Work managers(used at thread level)
We need not implement all three but which one to use depends upon requirements

Message throttling setup is really required for following reasons
  1. To prevent resource monopolizing
  2. To maintain good server health, ultimately preventing unexpected server downs
  3. Preventing resource starvation
For example, let's take a very common scenario in IT environments.If message consumer is down for routine maintenance and producer is up and producing huge number of messages then by the time consumer comes back online there will be huge number of messages piling up.
If there is no flow control enabled then, by default WLS creates many threads to meet the demand  which intern will start consuming all server resources just to process pending JMS messages.This will ultimately lead to resource starvation for other threads/processes running in the server.


Steps required to setup flow control

This can be achieved by two level setups
  1. Threshold setup on Queue under JMS module (Here we define min/max thresholds which triggers message throttling)














 2.  Connection factory flow control setup(Here we define how message producer should behave in case of threshold event)

















How it works?

When thresholds defined on destination reached(for example, max no of messages on a destination reached), since we have enabled "flow control" on connection factory, throttling will kick off automatically.Producers created using that CF will be instructed to control their message production as per numbers defined on CF.

Once Flow control kicks in, it will instruct message producer how fast or slow he has to produce messages to meet consumer speed.There will be no instructions provided to control consumer speed

Flow Maximum: Indicates how many messages a producer can generate per second when system is under flow control event

Flow Minimum: System will not slowdown producer further, if he is already generating messages per second equivalent to this value

Flow Interval: In how many seconds producer will come down from Flow Maximum to Flow Minimum, when system is under overloaded.It is a cool down period.In stead of rapid decreasing in production, producer goes steady slowdown causing smooth transition.

Flow Steps: Again second level of smooth transition.In how many breaks it will adjust flow interval
For example, if flow interval is 60 secs and flow steps is 10  then  60 divided by 10 = 6
in 6 breaks/pauses it will cool down the producer.

Throttling messages from consumer side
In a clustered environment, set following properties in consumer JMS JCA file 
<property name="minimumDelayBetweenMessages">10000 </property>

Delay is mentioned in milliseconds
Above properties causes JMS adapter to post messages to composite keeping 10000 secs gap between each message consumption.

Work managers
Though I have never tried this option,I believe we can throttle message processing using work managers also.Work managers is a weblogic way of expressing how client requests should be scheduled and processed.
Work managers can be defined and associated with deployment descriptors at various levels like domain(config.xml),application (weblogic-application.xml),EJB module level(weblogic-ejb-jar.xml) and web application(weblogic.xml)

As of version 11.1.1.6, we cannot associate work managers to BPEL composites  but can be assigned to OSB proxy and business services
I would recommend to explore this option too

Hope this helps

2 comments: