1
votes

My Mule application has an HTTP listener. I would like to receive ALL incoming messages and then route the message based on the path for e.g.

I have created the listener with the following properties:
host: www.myhost.com
port: 8080
path: /

I have then added a choice router that I would like to interrogate the incoming path and route the message based on the path ... for e.g.

http://www.myhost.com:8080/path1
http://www.myhost.com:8080/path2
http://www.myhost.com:8080/path3

At the moment when I run the application with no path it works ... but when I run it with one of the paths it fails with error ... "no listener endpoint configured for /path3"

Is there a way to configure the Mule HTTP listener to accept any path?

Thanks

2
Tell me. Are you using a RAML definition for your API ? Also, how many maximum paths or incoming messages are your expecting to process ? If you have a RAML definition and limited paths(resources), your mule generated flows will be automatically taken care by APIkit Router with path:/* and separate flows for each resource. Next you can flow-ref to your choice as you please, using some flags.Thinker-101

2 Answers

0
votes

You cannot hit an endpoint without using the absolute path of the listener.

In your case you have used your path:/

Hence this will not allow undeclared paths like path:/path1 etc.

You can try path:/* for allowing undeclared paths.

However, you can have multiple HTTP Listeners each with its own unique path but using the same Listener Configuration (Host, Port etc).

Since you need to take different choice routes for different paths, It's better to not use multiple paths, as you may have multiple routes possible.

You shouldn't do a one to one (1 -> 1) function mapping (like in mathematics) for your path Vs incoming messages.

/path is basically a resource for an API endpoint.

If you find you have 'n' number incoming messages, then you have to create 'n' of paths(resources) and 'n' HTTP Listeners(using same conf). But, this is not a good approach.

Instead use uriParams or queryParams just listening for one single path and then route your message based on these incoming parameters.

http://myhost.com:8080/basePath?route=1 // relevant body
http://myhost.com:8080/basePath?route=2 // relevant body
http://myhost.com:8080/basePath?route=3 // relevant body
0
votes

You can define your HTTP listener like this

<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/*"/>

the /* value for the path will allow any request to go through.

NOTE: this will not work if you are using RAML and APIKIT. You will get the APIKIT:NOT_FOUND error since all allowed paths have to be defined in the RAML spec when using APIKIT.