We are trying to perform the simplest publish / consume action among two different applications in the public VPC.
The publisher APP is working as expected. It generates the queue and publishes all the messages correctly.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<vm:config name="VM_Config" doc:name="VM Config" doc:id="1c2283b1-26a8-4fc9-b048-b50bbee08e62" >
<vm:queues >
<vm:queue queueName="order" queueType="PERSISTENT" />
</vm:queues>
</vm:config>
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="6f88c504-19e6-4cca-8b50-efb95b2dcbc8" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="sltestpqpubFlow" doc:id="23315e3e-49b0-4f61-a86c-321a2cb9c4ad" >
<http:listener doc:name="Listener" doc:id="2268dae5-2e89-45f4-a685-50602bea4205" config-ref="HTTP_Listener_config" path="/fire"/>
<vm:publish queueName="order" doc:name="Publish" doc:id="e928d591-4f4a-4d54-9390-3e69dd2520b8" config-ref="VM_Config">
<vm:content ><![CDATA[#["Message sent"]]]></vm:content>
</vm:publish>
<logger level="INFO" doc:name="Logger" doc:id="2eba63dd-15d0-4961-9c75-de8fee366caa" />
</flow>
</mule>
The listener APP on the other hand is creating its own persistent queue with the same name. Therefore, not consuming the messages published by the app mentioned above.
<mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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="VM_Config" doc:name="VM Config" doc:id="c9d8390d-cc35-4188-b034-70cb144f2da7">
<vm:connection >
<reconnection failsDeployment="true" >
<reconnect />
</reconnection>
</vm:connection>
<vm:queues >
<vm:queue queueName="order" queueType="PERSISTENT" />
</vm:queues>
</vm:config>
<flow name="sltestpqFlow" doc:id="1681828e-0889-4c2f-8f03-cebe7cf852cd" >
<vm:listener doc:name="Listener" doc:id="4b1a3db0-946d-4428-a7b8-b2e3aebd88fa" config-ref="VM_Config" queueName="order" transactionalAction="ALWAYS_BEGIN" transactionType="XA">
<reconnect />
</vm:listener>
<logger level="INFO" doc:name="Logger" doc:id="8efdd42a-9f73-4e07-80bd-b42cafed297f" message="Got event"/>
</flow>
</mule>
Not sure what we are missing for a single queue sharing (instead of each application having it's own)
UPDATE 02/20/2020 11:10 AM PST
We are using the VM Connector v2.0 in Mule 4
https://docs.mulesoft.com/connectors/vm/vm-reference
The VM connector only works inside the same JVM. In the case of applications deployed in CloudHub, it means inside the same application only. You can not share messages with any other applications. You need to bring your own JMS broker, installed somewhere where the applications can access it, some other message service with a connector for Mule 4, or use Anypoint MQ.
Related
I created a simple Restful web services in a mule project.
XML Config file of Restful WS:-
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http:listener-config name="American_HTTP_Listener_Configuration" host="0.0.0.0" port="8181" doc:name="HTTP Listener Configuration"/>
<flow name="americanFlow">
<http:listener config-ref="American_HTTP_Listener_Configuration" path="/api/flights" doc:name="HTTP" allowedMethods="GET"/>
<set-payload value="[{"ID":1, "code": "ER38sd","price": 400, "departureDate": "2016/03/20", "origin": "MUA", "destination": "SFO", "emptySeats": 0, "plane": {"type": "Boeing 737", "totalSeats": 150}}, {"ID":2,"code": "ER45if", "price": 345.99, "departureDate": "2016/02/11", "origin": "MUA", "destination": "LAX", "emptySeats": 52, "plane": {"type": "Boeing 777", "totalSeats": 300}}]" mimeType="application/json" doc:name="Set Payload"/>
</flow>
</mule>
And in the same project I created an another web services just to call the above Restful WS.
Below is the XML config file for calling WS:-
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:context="http://www.springframework.org/schema/context" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<context:property-placeholder location="flights-${env}.properties"/>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<http:request-config name="American_HTTP_Request_Configuration" protocol="HTTPS" host="localhost" port="8181" responseTimeout="300000" doc:name="HTTP Request Configuration"/>
<flow name="implemantationFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/american" allowedMethods="GET" doc:name="HTTP"/>
<flow-ref name="setAirportCodeSubFlow" doc:name="setAirportCodeSubFlow"/>
<http:request config-ref="American_HTTP_Request_Configuration" path="/api/flights" method="GET" doc:name="American REST Request"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
Here First I check the code with default response time, but a error is occur like "Error sending HTTP request". Later I changed default response time 30s to 300s still same error is coming.
Can anybody tell me how this problem get resolved? I've gone through lots of similar post but in all that posts, they're telling to increase the response time and check. But increasing the response time also can't help me to get out of this problem.
EDIT:- I also set the proxy to my Anypoint Studio.
In your request config put protocol="HTTP" instead of HTTPS
<http:request-config name="American_HTTP_Request_Configuration" protocol="HTTP" host="localhost" port="8181" responseTimeout="300000" doc:name="HTTP Request Configuration"/>
I want to write a mule application which will read the database for unprocessed records, club them in JSON payload format and then hit a REST webservice.
I am able to read the records from the database and able to convert the database records in JSON. However, whenever I run the application I am getting following exception
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
Here is my Mule configuration XML
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="root" database="my_database_name" doc:name="MySQL Configuration"/>
<http:request-config name="HTTP_Request_Configuration" protocol="HTTPS" host="example.net" port="8000" basePath="API" doc:name="HTTP Request Configuration"/>
<flow name="cwg_clientFlow">
<poll doc:name="Poll">
<db:select config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[SELECT * FROM cwg_ws_data WHERE SyncFlag = 0]]></db:parameterized-query>
</db:select>
</poll>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<json:object-to-json-transformer doc:name="Object to JSON" />
<logger message="JSON Payload is #[payload]" level="INFO" doc:name="Logger"/>
<http:request config-ref="HTTP_Request_Configuration" path="/cwg" method="POST" doc:name="HTTP">
<http:request-builder>
<http:query-params expression="#[payload]"/>
<http:header headerName="access_token" value="MQTgpMUmyQLt134maB6vPp6oWFgMtGsqzIlpCN74"/>
</http:request-builder>
</http:request>
<logger message="webservice response #[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
I am unable to understand where it is going wrong
Please help me, I am trying this since last 2 days.
Thanks in advance
-Paresh (kendreparesh#gmail.com)
Try removing this line.
<http:query-params expression="#[payload]"/>
It should work. As your payload is Json String and you are trying to map it to Query params which expects Map. Also for POST your payload will converted to body.
expression in query-params must be a map. If you are going to pass data as query-params, why are you doing object to json? Try removing below two lines -
<json:object-to-json-transformer doc:name="Object to JSON" />
<logger message="JSON Payload is #[payload]" level="INFO" doc:name="Logger"/>
Below is my flow. I need to call a REST service using PUT method. Using the same json request and the same service url it is working fine from Postman, but from Mule I am getting the error: "Cannot PUT /api/sms/send". Can someone please tell me what is wrong ?
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.7.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8093" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" protocol="HTTPS" host="api.example.com" port="443" doc:name="HTTP Request Configuration"/>
<flow name="testprojectFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" allowedMethods="GET" doc:name="HTTP"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
message_id: "d5c9af23-f1b2-4d5e-9d6b-439371e0009a",
dst_number: "1234567890",
src_number: "1234567891",
message_type: "SMS:TEXT",
message_data: "TEST MESSAGE SMS API",
submit_date: now
}]]></dw:set-payload>
</dw:transform-message>
<http:request config-ref="HTTP_Request_Configuration" path="/api/sms/send" method="PUT" doc:name="HTTP"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
My first Application is calling an other application but am not getting any response if i call the second application directly from SoapUI am getting response please help
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<flow name="stackFlow1" doc:name="stackFlow1">
<http:inbound-endpoint exchange-pattern="request-response" address="example.com/main" doc:name="HTTP"/>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" method="POST" doc:name="seconapp.co.io/flow"/>
</flow>
</mule>
The Second application xml is
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd">
<flow name="secondflowFlow1" doc:name="secondflowFlow1">
<http:inbound-endpoint exchange-pattern="request-response" address="seconapp.co.io/flow" doc:name="HTTP"/>
<cxf:jaxws-service doc:name="CXF"/>
<logger message="hello" level="INFO" doc:name="Logger"/>
</flow>
</mule>
I'm not completely sure the second app's endpoint is listeing on localhost, actually given that you use a hostname it is not:
<http:inbound-endpoint exchange-pattern="request-response" address="seconapp.co.io/flow" doc:name="HTTP"/>
You should try to change your first app outbound endpoint to:
<http:outbound-endpoint exchange-pattern="request-response" host="seconapp.co.io" path="flow" port="8081" method="POST" doc:name="seconapp.co.io/flow"/>
I am new to Mule and just trying to use mule to expose SOAP webservice. I used following example from mule soft http://www.mulesoft.org/documentation/display/current/XML-only+SOAP+Web+Service+Example. I am able to expose the webservice but getting error when DataMapper component tries to map Data from one request to another. Attached files contains required configurations. When I run the test xml on mapper using preview tab in Mule Studio it returns just: and says Your XML is not valid. Error: Premature End of File.
Please suggest.
Following is the configuration:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd ">
<data-mapper:config name="admitToUpsert" transformationGraphPath="admittoupsert.grf" doc:name="DataMapper"/>
<flow name="admitPatientService" doc:name="admitPatientService">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" doc:name="AdmissionService"/>
<cxf:proxy-service port="AdmissionPort" namespace="http://www.mule-health.com/SOA/service/admission/1.0" service="AdmissionService" payload="body" doc:name="Proxy Service" wsdlLocation="service/AdmissionService.wsdl"/>
<logger message="First request: #[message.payload]" level="INFO" doc:name="Logger"/>
<mulexml:dom-to-xml-transformer doc:name="Object to XML" returnClass="java.lang.String"/>
<logger message="Before hiting transfomer: #[message.payload]" level="INFO" doc:name="Logger"/>
<data-mapper:transform config-ref="admitToUpsert" doc:name="DataMapper"/>
<byte-array-to-string-transformer returnClass="java.lang.String" mimeType="text/plain" doc:name="Byte Array to String"/>
<logger message="Upsert Request is: #[message]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
Following is the Test xml:
<ns0:admitSubject xmlns:ns0="http://www.mule-health.com/SOA/service/admission/1.0" xmlns:ns1="http://www.mule-health.com/SOA/model/1.0">
<ns1:Referer>
<ns1:clientId>7899</ns1:clientId>
</ns1:Referer>
<ns1:Referral>
<ns1:procedure>
<ns1:code>In-patient</ns1:code>
<ns1:admission>Elective</ns1:admission>
<ns1:department>CARDIOLOGY</ns1:department>
</ns1:procedure>
</ns1:Referral>
<ns1:Subject>
<ns1:nationalId>4657</ns1:nationalId>
<ns1:firstName>Charles</ns1:firstName>
<ns1:lastName>Brown</ns1:lastName>
<ns1:address1>Any Street</ns1:address1>
<ns1:address2>?</ns1:address2>
<ns1:address3>?</ns1:address3>
<ns1:nationality>American</ns1:nationality>
<ns1:gender>Male</ns1:gender>
<ns1:dateOfBirth>1987-01-19</ns1:dateOfBirth>
</ns1:Subject>
</ns0:admitSubject>
WSDL and XSD can be pulled from https://github.com/mulesoft/Pre-sales-hospital-admission/tree/master/src/main/resources/service. Apologies for not pasting it here as it would have caused to much data on page but I can add them if requested
I am able to resolve this. It seems some special character got creeped in while copy pasting the xml. When I generated the XML from XSD in Mule studio it worked fine.