Skip to content

Instantly share code, notes, and snippets.

@JordanSchuetz
Created November 16, 2020 22:27
Show Gist options
  • Save JordanSchuetz/5cdbd69d81e9344edb5b070027599870 to your computer and use it in GitHub Desktop.
Save JordanSchuetz/5cdbd69d81e9344edb5b070027599870 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!-- websockets.xml -->
<mule
xmlns:java="http://www.mulesoft.org/schema/mule/java"
xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:websocket="http://www.mulesoft.org/schema/mule/websocket"
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: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/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/websocket
http://www.mulesoft.org/schema/mule/websocket/current/mule-websocket.xsd
http://www.mulesoft.org/schema/mule/scripting
http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd"
>
<sub-flow name="broadcastMessage" >
<websocket:broadcast doc:name="Broadcast" config-ref="WebSockets_Config" path="/log">
<websocket:content><![CDATA[#[output text/plain --- payload]]]></websocket:content>
</websocket:broadcast>
</sub-flow>
<flow name="on-new-connection" >
<websocket:on-inbound-connection doc:name="On New Inbound Connection" config-ref="WebSockets_Config" path="/log"/>
<logger level="INFO" doc:name="Logger" message='#["New Web Socket " ++ attributes.socketId]' />
</flow>
<flow name="on-new-message">
<websocket:inbound-listener doc:name="On New Inbound Message" config-ref="WebSockets_Config" path="/log"/>
<logger level="INFO" doc:name="Logger" message='#[output text/plain --- "Web Socket " ++ attributes.socketId ++ " message: " ++ payload]' />
</flow>
<flow name="on-connection-closed" >
<websocket:on-socket-closed doc:name="On Socket Closed" config-ref="WebSockets_Config" path="/log"/>
<logger level="INFO" doc:name="Logger" message='#["Web Socket " ++ attributes.socketId ++ " closed"]'/>
</flow>
</mule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment