I am working on migrating my Mule 2 project to Mule 3. However, since Mule 3.3 stop supporting dynamic inbound endpoint, I need to find an alternative way to rewrite my inbound endpoint.
Basically, I want to make http call to get some data from specific websites by using current system time as the query parameter. My codes in mule-config.xml is like the following
<flow name="RetrieveNewsService">
<http:inbound-endpoint host="www.awebsite.com" port="80" path="datacenter/someData.asp?category=1&date=[function:dateStamp:MMddyyyy]" connector-ref="RetrieveNewsPollingHttpConnector" exchange-pattern="one-way" />
//doing some process
</flow>
I feed current time for "path" part, and it works perfect in Mule 2, but get the exception mentioning about dynamic inbound endpoint is not supported anymore.
Anyone has any idea how to rewrite the dynamic path for inbound endpoint and what is the purpose they decide to stop this feature? Thanks for your time!
You can use a poll on an HTTP outbound-endpoint as demonstrated here:
<flow name="RetrieveNewsService">
<poll frequency="10000">
<http:outbound-endpoint method="GET" host="localhost"
port="8082" path="test?dtm=#[server.dateTime.format('MMddyyyy')]"
exchange-pattern="request-response" />
</poll>
//doing some process
</flow>
PS. No idea why.
Related
I am designing an application flow where I have to read a file (XML File) and put the data into IBM MQ (Queue). Do I need to create an HTTP request that will trigger the File read and update queue, otherwise how do I perform this task.
Currently I am creating an HTTP Request and connecting it to WMQ but I am getting NULL data into the Queue. Basically the payload is NULL.
This is the data I read when I browse the Queue:
sr.org.mule.transport.NullPayload1.L5U���...xp
Try like this:
Whenever you use File connector at any other place than the beginning of the flow, then it becomes an outbound endpoint.
For using File as an inbound endpoint to retrieve any file, you must use it in the beginning of some flow & keep the flow in stopped state initially as:
<flow name="filePickupFlow" initialState="stopped">
<file:inbound-endpoint path="src/main/resources/input" responseTimeout="10000" doc:name="File"/>
<wmq:outbound-endpoint queue="gh" doc:name="WMQ" connector-ref="WMQ"/>
</flow>
For your case just change the path with your required file location.
Then for further calling it via http, create another flow with http endpoint & use an Expression component to start the flow containing file inbound endpoint call as :
<expression-component doc:name="Expression">
app.registry.filePickupFlow.start();
</expression-component>
Then if you wish to stop it after it completes processing, you can again use an Expression component as:
<expression-component doc:name="Expression">
Thread.sleep(5000);
app.registry.filePickupFlow.stop();
</expression-component>
Thread.sleep() is used here just to give some time gap between flow start & stop to let the flow operation complete. You can add some other thing for maintaing this time gap or set the time according to your own usage.
I guess this is what you were looking for.
Regards,
JJ
If you want to access the file component on-demand( Whenever you access the HTTP, only then File component needs to access), use Mule Requester in the place of file component which do the same work.
<mulerequester:config name="Mule_Requester" doc:name="Mule Requester"/>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" basePath="test2" doc:name="HTTP Listener Configuration"/>
<flow name="httpFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<mulerequester:request config-ref="Mule_Requester" resource="file://C:/in" doc:name="Mule Requester"/>
<object-to-string-transformer doc:name="Object to String"/>
<logger message="**payload:*#[payload]" level="INFO" doc:name="Use WMQ here instead of Logger"/>
</flow>
Link to refer: https://github.com/mulesoft/mule-module-requester/blob/master/mulerequesterdemo/src/main/app/MuleRequesterDemo.xml
Instead of HTTP, you can also schedule job trigger using Poll component based on your requirement. Hope this helps.
You wanted to used file connector as inbound endpoint but actually using as outbound endpoint. Check your configuration xml file for file connector.
There are many ways for reading file as inbound like file connector, Poll scope or Quartz connector. You can use anyone of these as per you requirement. The simplest flow is as
<flow name="testfixedFlow">
<file:inbound-endpoint path="tmp" connector-ref="File" responseTimeout="10000" doc:name="File"/>
<wmq:outbound-endpoint queue="xyz" connector-ref="WMQ" doc:name="WMQ"/>
</flow>
But if you want to get resource in between the flow you can use Mule requester
Hope this helps.
I have the following flow, attempting to use the new http connector in Mule 3.6 with the http:static-resource-handler:
<flow name="facebook-sources-apiFlow1">
<http:listener config-ref="HTTP_Listener_Configuration" path="/admin" doc:name="HTTP"/>
<http:static-resource-handler resourceBase="${app.home}/web" defaultFile="index.html" doc:name="HTTP Static Resource Handler"/>
</flow>
I have a directory called 'web' under src/main/app, and an index.html in the web directory. When I try this, though, I get the following error:
null (java.lang.NullPointerException). Message payload is of type: NullPayload
Before sinking too much time into the problem, I thought I'd ask if the new http connector even works with the static-resource-handler.
I'm afraid you can't. There is a bug around this: https://www.mulesoft.org/jira/browse/MULE-8317
I have two flows in mule. I want to make one of them start , only after the other has been up and running for a while. how can I do that? Thanks
<flow name="newHttpClientRequestProcessor" doc:name="newHttpClientRequestProcessor">
<flow name="RestNewHttpClientRequestFlow" doc:name="RestNewHttpClientRequestFlow">
<http:inbound-endpoint exchange-pattern="one-way" host="localhost" port="8082" path="subscription" doc:name="HTTP"/>
<jersey:resources doc:name="REST">
<component class="com.citi.isg.rest.endpoints.RestNewHttpClientEndpoint"/>
</jersey:resources>
</flow>
This is similar to what I replied to this recent question: https://stackoverflow.com/a/14633484/387927
Configure the flow that must not be initially started with initialState="stopped"
Whenever you want to start it, use the following MEL expression: app.registry.FLOWNAME.start();, replacing FLOWNAME with the name of the flow you want to start.
I need to programmatically start or stop a flow or endpoint from another flow. Can this be done? Is there risk of message loss?
<flow name="control>
<vm:inbound-endpoint path="in">
<script:component>
<!-- start/stop -->
</script:component>
</flow>
<flow name="startable-stoppable>
<any-transport:inbound-endpoint/>
<component/>
</flow>
After some research I've found that the best option in my case is to start/stop the connectors associated with the endpoints I want to control.
<script:component>
<script:script engine="groovy">
muleContext.getRegistry().lookupConnector('connectorName').start() // or stop()
</script:script>
</script:component>
A disadvantage of this approach is that all the endpoints associated with the connector will be affected. If this is a problem, every endpoint should have its own connector.
You can control the lifecycle of Mule moving parts with JMX: use JConsole to find out what MBean you need to access from your scripted component.
i am creating one webservice in mule using cxf:jaxws-service. This is the url :http://localhost:65042/InsertDocService/InsertDoc, i am ablie to generate WSDL file, but i want to consume this service in mule using cxf:jaxws-client.
<flow name="documentumclientflowFlow1" doc:name="documentumclientflowFlow1">
<inbound-endpoint address="http://localhost:65042/InsertDocumentumService/InsertDocumentum" doc:name="Generic"/>
<cxf:jaxws-client operation="insertDocumentum" serviceClass="com.integration.IDocumentumInsert" port="80" mtomEnabled="true" enableMuleSoapHeaders="true" doc:name="SOAP"/>
<outbound-endpoint address="http://locahhost:65042/InsertDocumentumService/InsertDocumentum" doc:name="Generic"/>
</flow>
if i invoke this, it's going to Service project and getting erorr like"org.apache.cxf.interceptor.Fault: No such operation: (HTTP GET PATH_INFO: /InsertDocumentumService/InsertDocumentum)". Please any one suggest me how can i solve this issue and how can i consume this service.
Besides the type (locahhost instead of localhost), it looks like you're trying to use the same address in the outbound endpoint than in the inbound one. I don't think this is what you want to do, as it will lead to a looping re-entrant call that will eventually exhaust the pool threads, block, time out and die in a fire.
So what do you want to do with "documentumclientflowFlow1"? It is unclear from your question.