3

I am trying to integrate JIRA with Salesforce through cloudhub application. I have created a mule soft project (which is invoked each time when a worklog is updated or created in JIRA) and deployed it in cloudhub. From Jira I am using web hook instance which calls mule project in cloud hub. The problem I am facing is when simultaneous calls are made from JIRA to cloudhub application,java classes in the project flow are getting executed simultaneously by parallel calls from JIRA and variables gets overridden and creates conflicts. How can I make the HTTP requests processing one at a time in mule project?

  • Performance-wise, I think you should fix that variable-access conflict as forcing requests to be process one at a time will hurt performance. From my understanding, you seem to be using a globally-shared variable (perhaps thru static variable or singleton object). Simply making that non-static var or a prototype object should avoid the issue.. In any case, updating it to one thread is the easiest fix (go with Gabriel's solution below) – Avanaur Aug 24 '15 at 14:43

2 Answers2

0

To set threads on HTTP listener use:

<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration">
    <http:worker-threading-profile maxThreadsActive="1" />
</http:listener-config>
Gabriel Dimech
  • 699
  • 5
  • 10
  • As per http://stackoverflow.com/questions/29096104/limiting-http-listener-active-threads-to-control-number-of-concurrent-mule-flow, you still need to specify Poll Exhausted Action to WAIT. Otherwise, it will not have an effect. – Avanaur Aug 24 '15 at 14:45
  • Agreed, I missed this one. – Gabriel Dimech Aug 24 '15 at 14:51
0

Your question implies to me that you are using a custom java class in order to transform your JIRA data so that it can be sent to Salesforce, and that it has static variables or some other shared state that is not thread safe.

To resolve your concurrency problem, try to implement your flow so that it does not need to be single threaded:

  1. First, if you can, implement the transformation logic using built-in Mule Message Processors and Mule Expression Language. If you're on 3.7+, I'd encourage you to try it with DataWeave. These are implicitly thread safe.

  2. If you do implement custom java, try to eliminate the use of shared state. This can be in the form of static variables, or it could happen with instance variables if you are using a spring bean with Singleton scope (which is the default).

  3. If you need shared state in a custom java message processor, use the Mule Object Store to store the state instead of java instance variables or static variables. There is a connector that allows you to add and retrieve data from the object store from your flow directly, as well.

Ryan Hoegg
  • 2,415
  • 2
  • 14
  • 15