Search code examples
javasocketsmuleesbmule-flow

Anypoint Studio-Mule ESB create custom Socket Listener


i need to implement a simple mule esb flow with Anypoint Studio.

What i need is to open-up a socket listener on the starting of the flow, and sending to a second Java component the messages which came to the listener...

Can anybody point me to the right direction?


Solution

  • You can use a tcp:connector or ssl:connector, for example:

    <!-- Connector --> 
    <tcp:connector name="tcpConnector" validateConnections="true" receiveBufferSize="102400" clientSoTimeout="10000" receiveBacklog="0" sendBufferSize="0" serverSoTimeout="10000" socketSoLinger="0" doc:name="TCP connector"> 
        <tcp:eof-protocol payloadOnly="true" rethrowExceptionOnRead="true"/> 
    </tcp:connector>
    
    <!-- Endpoints -->    
    <tcp:endpoint name="tcpEndpoint" host="${tcp.endpoint.host}" port="${tcp.endpoint.port}" responseTimeout="10000" doc:name="TCP"/>
    
    <flow name="tcpFlow" doc:name="tcpFlow">
       <inbound-endpoint ref="tcpEndpoint" doc:name="Generic"/>
       <logger level="INFO" doc:name="log" message="Receive payload #[payload]" />
       <component class="...Component" doc:name="" doc:description=""/>
    </flow>