Time for action – increasing listener threads

Now let us add the maxThreads property to our InVM service and see how that affectsour output:

  1. Modify the jboss-esb.xml file and add the maxThreads property with a value of 5:
    <service category="Chapter5Sample" 
             description="Chapter5 B Service"
             invmScope="GLOBAL" name="Chapter5BService">
      <property name="maxThreads" value="5"/>
      <property name="inVMLockStep" value="true"/>
      <property name="inVMLockStepTimeout" value="4000"/>
      <actions mep="OneWay">
        <action class="org.jboss.soa.esb.samples.chapter5.MyAction"
                name="lockStepAction" process="lockStepAction"/>
        <action class="org.jboss.soa.esb.actions.SystemPrintln"
                name="printMessage">
          <property name="message" value="Incoming to B"/>
        </action>
      </actions>
    </service>
  2. Click on Save or press Ctrl + S.
  3. If the server was still running then you might notice the application gets redeployed once again by default. If this did not happen then deploy the application using Run | Run As | Run on Server.
  4. Select the src folder and expand it till the SendLockStepMessage.java file is displayed in the tree. Now click Run | Run As | Java Application.

    The following is the server console output from a sample run:

    15:30:49,687 INFO  [STDOUT] Routing to B
    15:30:49,718 INFO  [STDOUT] Routing to B
    15:30:49,718 INFO  [STDOUT] Routing to B
    15:30:49,718 INFO  [STDOUT] Routing to B
    15:30:49,718 INFO  [STDOUT] Routing to B
    15:30:49,718 INFO  [STDOUT] Routing to B
    15:30:51,703 INFO  [STDOUT] Incoming to B:
    15:30:51,703 INFO  [STDOUT] [Chapter 5 says Hello!].
    15:30:51,718 INFO  [STDOUT] Incoming to B:
    15:30:51,718 INFO  [STDOUT] [Chapter 5 says Hello!].
    15:30:51,718 INFO  [STDOUT] Routing to B
    15:30:51,718 INFO  [STDOUT] Incoming to B:
    15:30:51,718 INFO  [STDOUT] [Chapter 5 says Hello!].
    15:30:51,718 INFO  [STDOUT] Routing to B
    15:30:51,718 INFO  [STDOUT] Incoming to B:
    15:30:51,718 INFO  [STDOUT] [Chapter 5 says Hello!].
    15:30:51,718 INFO  [STDOUT] Routing to B
    15:30:51,718 INFO  [STDOUT] Incoming to B:
    15:30:51,718 INFO  [STDOUT] [Chapter 5 says Hello!].
    15:30:51,718 INFO  [STDOUT] Routing to B
    15:30:53,718 INFO  [STDOUT] Incoming to B:
    15:30:53,718 INFO  [STDOUT] [Chapter 5 says Hello!].
    15:30:53,718 INFO  [STDOUT] Incoming to B:
    15:30:53,718 INFO  [STDOUT] [Chapter 5 says Hello!].
    15:30:53,718 INFO  [STDOUT] Incoming to B:
    15:30:53,718 INFO  [STDOUT] [Chapter 5 says Hello!].
    15:30:53,718 INFO  [STDOUT] Incoming to B:
    15:30:53,718 INFO  [STDOUT] [Chapter 5 says Hello!].
    15:30:53,718 INFO  [STDOUT] Incoming to B:
    15:30:53,718 INFO  [STDOUT] [Chapter 5 says Hello!].
    

What just happened?

You increased the InVM listener threads for our Chapter5Bservice from 1 to 5. Notice that the Routing to B message is displayed five times initially and the sixth is blocked until another listener thread becomes available. Although Chapter5Service picked up its sixth message to route it to Chapter5Bservice it has been blocked and hence the seventh message is picked up only after two seconds.

Have a go hero – threads and lock-step

Play around with different numbers of messages and maxThreads values and examine how the output behaves. Go ahead and remove the invmLockStep and inVMLockStepTimeout attributes and see what difference it produces in the output of the server console.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset