Skip to content

Commit

Permalink
Support properties for vm consumers (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
svacas authored May 25, 2022
1 parent 8be6705 commit 28b4f06
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ public void execute(Element object, MigrationReport report) throws RuntimeExcept
connector.ifPresent(conn -> {
handleServiceOverrides(conn, report);

Integer consumers = null;
String consumers = null;
if (conn.getAttribute("numberOfConcurrentTransactedReceivers") != null) {
consumers = parseInt(conn.getAttributeValue("numberOfConcurrentTransactedReceivers"));
consumers = conn.getAttributeValue("numberOfConcurrentTransactedReceivers");
} else if (conn.getChild("receiver-threading-profile", CORE_NAMESPACE) != null
&& conn.getChild("receiver-threading-profile", CORE_NAMESPACE).getAttribute("maxThreadsActive") != null) {
consumers = parseInt(conn.getChild("receiver-threading-profile", CORE_NAMESPACE).getAttributeValue("maxThreadsActive"));
consumers = conn.getChild("receiver-threading-profile", CORE_NAMESPACE).getAttributeValue("maxThreadsActive");
}

if (consumers != null) {
getContainerElement(object).setAttribute("maxConcurrency", "" + consumers);
object.setAttribute("numberOfConsumers", "" + consumers);
getContainerElement(object).setAttribute("maxConcurrency", consumers);
object.setAttribute("numberOfConsumers", consumers);
}

handleConnectorChildElements(conn, vmConfig, new Element("connection", CORE_NAMESPACE), report);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public static Object[] params() {
"vm-inbound-13",
"vm-inbound-14",
"vm-inbound-15",
"vm-inbound-16"
"vm-inbound-16",
"vm-inbound-17",
"vm-inbound-18"
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">

<vm:connector name="vmConnector" numberOfConcurrentTransactedReceivers="${max.vm.thread.count}">
<vm:queue-profile maxOutstandingMessages="2"/>
</vm:connector>

<flow name="flow">
<vm:inbound-endpoint path="in" exchange-pattern="request-response" />
<logger/>
</flow>

</mule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:compatibility="http://www.mulesoft.org/schema/mule/compatibility"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">

<vm:config name="vmConnector">
<vm:queues>
<vm:queue queueName="in" queueType="TRANSIENT" maxOutstandingMessages="2"/>
</vm:queues>
</vm:config>

<flow name="flow" maxConcurrency="${max.vm.thread.count}">
<vm:listener config-ref="vmConnector" queueName="in" numberOfConsumers="${max.vm.thread.count}" >
<vm:response>
<vm:content>#[output application/java --- {'_vmTransportMode': true, 'payload': payload.^raw, 'mimeType': payload.^mimeType, 'session': vars.compatibility_outboundProperties['MULE_SESSION']}]</vm:content>
</vm:response>
</vm:listener>
<compatibility:attributes-to-inbound-properties/>
<logger/>
<compatibility:outbound-properties-to-var consumeStreams="true"/>
</flow>

</mule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">

<vm:connector name="vmConnector">
<receiver-threading-profile
maxThreadsActive="${max.receiver.threads}" />
<dispatcher-threading-profile
maxThreadsActive="${max.dispatcher.threads}" />
<vm:queue-profile maxOutstandingMessages="${max.outstanding.messages}"/>
</vm:connector>

<flow name="flow">
<vm:inbound-endpoint path="in" exchange-pattern="request-response" />
<logger/>
</flow>

</mule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:compatibility="http://www.mulesoft.org/schema/mule/compatibility"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">

<vm:config name="vmConnector">
<vm:queues>
<vm:queue queueName="in" queueType="TRANSIENT" maxOutstandingMessages="${max.outstanding.messages}"/>
</vm:queues>
</vm:config>

<flow name="flow" maxConcurrency="${max.receiver.threads}">
<vm:listener config-ref="vmConnector" queueName="in" numberOfConsumers="${max.receiver.threads}" >
<vm:response>
<vm:content>#[output application/java --- {'_vmTransportMode': true, 'payload': payload.^raw, 'mimeType': payload.^mimeType, 'session': vars.compatibility_outboundProperties['MULE_SESSION']}]</vm:content>
</vm:response>
</vm:listener>
<compatibility:attributes-to-inbound-properties/>
<logger/>
<compatibility:outbound-properties-to-var consumeStreams="true"/>
</flow>

</mule>

0 comments on commit 28b4f06

Please sign in to comment.