webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Implementing Server Sent Events (SSE) in the IS

  • 1.  Implementing Server Sent Events (SSE) in the IS

    Posted Wed August 24, 2022 07:58 PM

    What product/components do you use and which version/fix level?

    webMethods 10.3

    Are you using a free trial or a product with a customer license?

    Product with a customer license

    What are trying to achieve? Please describe in detail.

    The final goal is implementing a SSE PoC using a browser as the client and the IS as the server.

    The client-side is almost done (reference: What is Server-Sent Events (SSE) and how to implement it? | by Gökhan Ayrancıoğlu | Delivery Hero Tech Hub | Medium)

    The issue is currently regarding the server side. The question is similar to How to respond to http client without completing the flow service., but there is a catch:

    • in the meantime the connection is open, HTTP responses output should be sent out right away - i.e. before the service finishes.

    Based on the previous attempts, the pub.flow:setResponse and pub.flow:setResponse2 (services), or using the $httpResponse, they all “flush” the response buffer only after the service finishes.

    Do you get any error messages? Please provide a full error message

    Not applicable.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 2.  RE: Implementing Server Sent Events (SSE) in the IS

    Posted Fri September 02, 2022 09:32 AM

    Hi @Feng_Sian5
    IS doesn’t support SSE specification but can you see if WebSocket support in IS can be explored to achieve the requirements.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Implementing Server Sent Events (SSE) in the IS

    Posted Wed April 23, 2025 08:58 AM

    Although the IS does not directly support Server Sent Events (SSE), it does provide the means to implement it.

    You need a Java Service in which you enter a loop that only completes when the client closes the connection. In the mean time, you need to get hold of the output stream of the socket the client is connect too, and start writing events to it.

    The Java API of the IS gives you the right clues:

    java.io.OutputStream os = InvokeState.getCurrentSocket().getOutputStream();

    Using the SSE specification you can compose your event and write it to the client:

    os.write(event);

    Follow the SSE example on MDN to write a client that receives and processes events.

    I imagine that on the IntegrationServer you also would like to have:

    • a service that you can invoke that sends an event of a certain type to all connected clients.
    • a service that lists all connected clients

    If you don't want to piece everything together yourself, you can find worked example here: https://integrationwise.biz/sse.html.

    Cheers!



    ------------------------------
    Ido-Eduard de Baat
    ------------------------------