How to get Client IP from UDP Transport in Mule ESB? - udp

I'm trying to get the client IP and socket of a UDP package and save it in a Flowvar variable using the MEL code
#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]
However this variable is always null, I have been able to make it work on TCP transport, does anyone know how to get the remote client address in UDP?
This is my XML file:
<mule xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:udp="http://www.mulesoft.org/schema/mule/udp" 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/udp http://www.mulesoft.org/schema/mule/udp/current/mule-udp.xsd
http://www.mulesoft.org/schema/mule/amqp http://www.mulesoft.org/schema/mule/amqp/current/mule-amqp.xsd">
<udp:connector name="UDP" validateConnections="true" keepSendSocketOpen="true" doc:name="UDP" broadcast="true"/>
<flow name="udpFlow">
<udp:inbound-endpoint exchange-pattern="one-way" host="172.22.20.103" port="4040" connector-ref="UDP" responseTimeout="10000" doc:name="UDP" metadata:id="9260547c-3b58-4ebd-953e-fd3e7bb063f3"/>
<object-to-string-transformer doc:name="Object to String"/>
<set-variable variableName="source" value="#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]" metadata:id="6a72ad72-167f-44da-9f3d-75143c5c0a2f" doc:name="Variable"/>
<set-payload value="#[flowVars.source] dice #[payload]" doc:name="Set Payload"/>
<echo-component doc:name="Echo"/>
</flow>
</mule>
UPDATE:
I solve the Address issue with the MEL code
#[message.inboundProperties['packet.address']]: #[message.inboundProperties['packet.port']]
Thanks to David Dossot for his help.

Use:
#[message.inboundProperties['packet.address']]

Related

No valid operation is selected by Dropbox connector in mule

I try to create a simple application using Mule. Anyway when I select operation "Authorize" I got error. But if I select another operation it works fine!!
I have Mule Server version="CE-3.8.1" and use Anypoint studio Version: 6.2.5
The Complete XML Configuration:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:dropbox="http://www.mulesoft.org/schema/mule/dropbox" 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://www.mulesoft.org/schema/mule/dropbox http://www.mulesoft.org/schema/mule/dropbox/current/mule-dropbox.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<http:listener-config name="HTTP_Listener_Configuration8881" host="localhost" port="8881" doc:name="HTTP Listener Configuration"/>
<dropbox:config name="Dropbox1" appKey="ovy1i8ak8u43t87" appSecret="7jlhpdzeyddi8d5" doc:name="Dropbox">
<dropbox:oauth-callback-config domain="localhost" localPort="8881" remotePort="8881" path="callback"/>
</dropbox:config>
<http:request-config name="HTTP_Request_Configuration" host="www.mulesoft.com" port="80" doc:name="HTTP Request Configuration"/>
<flow name="dropbox_integration2Flow">
<http:listener config-ref="HTTP_Listener_Configuration8881" path="/authorize" doc:name="HTTP"/>
<dropbox:unauthorize config-ref="Dropbox1" doc:name="Dropbox - authorize"/>
</flow>
<flow name="dropbox_integration2Flow1">
<http:listener config-ref="HTTP_Listener_Configuration8881" path="/" doc:name="HTTP"/>
<dropbox:create-folder config-ref="Dropbox1" path="/mule" doc:name="Dropbox - create"/>
<http:request config-ref="HTTP_Request_Configuration" path="/sites/default/files/3C_mulesoft_logo_updated.svg" method="GET" doc:name="HTTP"/>
<dropbox:upload-stream config-ref="Dropbox1" filename="mulelogo.png" path="/mule" doc:name="Dropbox - upload"/>
<dropbox:get-link config-ref="Dropbox1" path="/mule/mulelogo.png" doc:name="Dropbox - get link"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
</mule>
Is there any reason for this? How to fix it?
It seems to be a bug in the old Mule Dropbox Cloud Connector Mule Studio Extension 3.3.0 (2013). Are you using that one? If you are, I suggest you use the latest available version, Dropbox Connector 3.3.3 (2015), which fixes the error.

amqp ssl connection error

Hi I am trying to create a very simple AMQP connector to talk to my localhost RabbitMQ server using SSL. Without SSL, the connection works fine but I suspect my SSL configuration is incorrect. Can anyone shed light on this? I'm quite a newbie to Mule so apologies if this is ridiculous.
</ssl:connector>
<flow name="here_we_go_againFlow1">
<amqp:inbound-endpoint exchangeName="sales_exchange" queueName="sales_queue" responseTimeout="10000" exchange-pattern="request-response" connector-ref="AMQP_0_9_Connector" doc:name="AMQP-0-9" ref="AMQP_0_9"/>
<ssl:outbound-endpoint host="localhost" port="5671" responseTimeout="10000" doc:name="SSL (TLS)"/>
<echo-component doc:name="Echo"/>
</flow>
I assume you are trying to connect to an AMQP server over SSL. Here is an example using the ampqs transport. Note the namespaces etc.
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:amqps="http://www.mulesoft.org/schema/mule/amqps" xmlns:spring="http://www.springframework.org/schema/beans"
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/amqps http://www.mulesoft.org/schema/mule/amqps/current/mule-amqps.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<amqps:connector name="amqpsDefaultSslConnector" />
<flow name="amqp">
<amqps:inbound-endpoint exchangeName="target-exchange"
exchangeType="fanout" exchangeDurable="true" exchangeAutoDelete="false"
queueName="target-queue" queueDurable="true" queueAutoDelete="false"
queueExclusive="true" routingKey="a.b.c" connector-ref="amqpsDefaultSslConnector" />
....
</flow>
</mule>
There's also more advanced configuration such as setting up key stores etc. Examples can be found here: https://github.com/mulesoft/mule-transport-amqp/blob/master/mule-transport-amqp/src/test/resources/amqps-namespace-config.xml

Making WebMQ Synchronous

I'm trying to make WebMQ act synchronously in MULE in order to turn the message queue into a REST api for an internal project. Unfortunately, I know very little about MULE.
After a good bit of work, I started understanding the Request-Reply scope and tried to use the WMQ Connector with it, only to find out that WMQ only sends once the flow has ended.
I've tried putting the request into a different flow using VM to trigger it
but so far that just leads to it waiting forever on WMQ that will never happen.
I've also tried using VMs for back and forth:
But it seems to do the same thing as without, where it just ignores the input.
Now I know the input and output for the WMQ are working, as I previously setup a flow that used http to communicate with itself and let it know when a message went through.
What I essentially want is this, but using HTTP instead of AJAX
My latest, and perhaps closest attempt looks like thus:
The XML being:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" version="EE-3.6.0" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:ajax="http://www.mulesoft.org/schema/mule/ajax" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio" xmlns:test="http://www.mulesoft.org/schema/mule/test" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ajax http://www.mulesoft.org/schema/mule/ajax/current/mule-ajax.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.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/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/current/mule-test.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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.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/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">
<wmq:connector channel="MAGENTO.SVRCONN" doc:name="WMQ Connector" hostName="[ip]" name="wmqConnector" port="1414" queueManager="MAGENTO" transportType="CLIENT_MQ_TCPIP" validateConnections="true" />
<vm:connector name="VM" validateConnections="true" doc:name="VM">
<vm:queue-profile maxOutstandingMessages="500">
<default-persistent-queue-store/>
</vm:queue-profile>
</vm:connector>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="Input">
<http:listener config-ref="HTTP_Listener_Configuration" path="/mq" doc:name="HTTP"/>
<set-payload value="#[message.inboundProperties.'http.query.params'.xml]" doc:name="Set Payload"/>
<logger message="Entering Request-Reply Payload: #[payload]" level="INFO" doc:name="Logger"/>
<request-reply doc:name="Request-Reply">
<vm:outbound-endpoint exchange-pattern="one-way" path="mq" connector-ref="VM" doc:name="VM_TriggerSend" />
<vm:inbound-endpoint exchange-pattern="request-response" path="mq-return" connector-ref="VM" doc:name="VM_Receive" />
</request-reply>
<logger message="Request-Reply has ended. Payload: #[payload]" level="INFO" doc:name="Logger"/>
</flow>
<flow name="Send_Message">
<vm:inbound-endpoint exchange-pattern="one-way" path="mq" connector-ref="VM" doc:name="VM_Send"/>
<logger message="(Preparing to Dispatch) Payload: #[payload]" level="INFO" doc:name="Logger"/>
<wmq:outbound-endpoint queue="PUT_QUEUE" connector-ref="wmqConnector" doc:name="WMQ"/>
<logger message="Message presumably being dispatched after this log" level="INFO" doc:name="Logger"/>
</flow>
<flow name="Receive_Message">
<wmq:inbound-endpoint queue="GET_QUEUE" connector-ref="wmqConnector" doc:name="WMQ_Receive" />
<logger message="Triggering Receive" level="INFO" doc:name="Logger"/>
<vm:outbound-endpoint exchange-pattern="request-response" path="mq-return" connector-ref="VM" doc:name="VM_TriggerReceive" />
</flow>
</mule>
Which almost works, but it hangs indefinitely without sending a response back to the HTTP server. Setting the vm:inbound-endpoint in the Request-Reply flow to one-way keeps it from hanging, but doesn't send the new payload that's been received, but instead the previous payload (as if it's being skipped over).
Any help at all would be greatly appreciated!
If I understood correctly you are just trying to expose a request on a queue and a response on a well known queue as a REST api.
There is no need of VM queues there, and neither request-reply elements as the JMS transport can simulate the request response exchange pattern.
JMS queues are just one way. You have to necesarily reply on a different queue. The logic behind a request-response scenario is an outbound-endpoint that having an outbound property: MULE_REPLYTO. This property should be set with the name of your well known reply to queue: GET_QUEUE (if no such header is provided a temporary queue will be created).
The MULE_REPLY to header will become the standard JMSReplyTo when the mesasge is received at the service. The service has to honor this header sending the reply back to that queue. If the service is implemented on Mule this will happen automatically, otherwise it might not happen. You should double check its being honored.
If you want to use a request-reply scope with to one-way endpoints rather than one request-reponse endpoint, it is fine, should work the same but with more code.
Making an Asynchronous datasource Synchronous can indeed be tricky. But I don't really see an issue with your request-reply strategy.
Try to use an request-reply with WMQ endpoint on both sides. Then monitor the queues and see that the message and reply arrives as they should. Do you use the same queue for the request and the reply? The simplest scenario would be to use different ones, is that possible for your use-case?

Anypoint Enterprise Security IP Filter

Hi I am working with Mule Anypoint Studio and I am trying to implement a list of IP's but my program is allowing every request from all IP's and it works only for one request per browser. How it is working i have no Idea. Please elaborate the working . Please don't share Mule Documentation Link because there they have not given much information.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:filters="http://www.mulesoft.org/schema/mule/filters" 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.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/filters http://www.mulesoft.org/schema/mule/filters/current/mule-filters.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<filters:config name="Filters" doc:name="Filters"/>
<flow name="mule-security-ipFlow1" doc:name="mule-security-ipFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="196.111.1.1" port="8081" doc:name="HTTP" path="ip"/>
<filters:filter-by-ip config-ref="Filters" regex="196.16.4.1,196.17.7.13" doc:name="Filters"/>
<set-payload value="#['Data Mast']" doc:name="Set Payload"/>
<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
there are two scenarios here, we can specify regular expression to allow certain ip range requests or we can specify single ip address as part regex attaribute value.
<filters:filter-by-ip config-ref="Filters" regex="${fms.iprange}"
doc:name="verify-ip-address" />
if we want to allow comma separated ip address, its better to write custom filter and do the required logic .
Depending on how you are intending to deploy your flow your other option is to use api-kit to apply the IP whitelist (or blacklist) to your flow as a policy:

Mule ESB and maximum flow threads

I went to the following site:
http://www.mulesoft.org/documentation/display/current/Tuning+Performance
and it says to alter the following 2 values:
maxThreadsActive and maxBufferSize
with maxThreadsActive being the number of active threads at anyone time, and maxBufferSize being the number of requests that can wait in a queue
But I am having difficulty finding any examples of how to do this in code.
-- Is there a central Mule ESB file where I can change the default number of maxThreadsActive and maxBufferSize ???
Would this be the dispatcher threading profile. What file would that be ?
--
If there is no central filet, for a synchronous process, how would I change the following code to use a maximum number of active threads to 100 and a maximum number of requests on the queue to 60
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:db="http://www.mulesoft.org/schema/mule/db" 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.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/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd">
<db:generic-config name="Generic_Database_Configuration" url="jdbc:db2://localhost:50000/TEST:user=instuid;password=instpw;" driverClassName="com.ibm.db2.jcc.DB2Driver" doc:name="Generic Database Configuration"/>
<http:endpoint exchange-pattern="request-response" host="localhost" port="8081" method="POST" name="HTTP" doc:name="HTTP"/>
<flow name="test1Flow1" doc:name="test1Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" contentType="application/json" keepAlive="true" mimeType="application/json"/>
<echo-component doc:name="Echo"/>
</flow>
</mule>
Thanks
You can used a queued-asynchronous processing strategy in you flow. With this approach you can change the number of threads available to the flow.
For Example:
<queued-thread-per-processor-processing-strategy name="ProcessingStrategy" maxThreads="60" minThreads="10" threadTTL="5000" poolExhaustedAction="WAIT" threadWaitTimeout="5000" maxBufferSize="100"/>
<flow name="test1Flow1" doc:name="test1Flow1" processingStrategy="ProcessingStrategy">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" contentType="application/json" keepAlive="true" mimeType="application/json"/>
<echo-component doc:name="Echo"/>
</flow>
"You can specify a separate threading profile for each receiver thread pool, flow thread pool, and dispatcher thread pool". For example:
<http:connector name="DefaultHTTPConnector" clientSoTimeout="120000" keepSendSocketOpen="false" >
<receiver-threading-profile maxThreadsActive="500"/>
<dispatcher-threading-profile maxThreadsActive="500"/>
</http:connector>
or
<configuration>
<default-receiver-threading-profile maxThreadsActive="130" />
</configuration>
I recommend the first option in the flow.
I hope to help;
You cannot add a flow processing strategy on a request-response exchange pattern
Add a global configuration element as follows: