Class EventStream

java.lang.Object
energy.eddie.outbound.rest.web.EventStream

@Component public class EventStream extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.springframework.http.MediaType
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> org.springframework.http.ResponseEntity<reactor.core.publisher.Flux<T>>
    toJson(reactor.core.publisher.Flux<T> stream)
     
    <T> org.springframework.http.ResponseEntity<reactor.core.publisher.Flux<String>>
    toXml(reactor.core.publisher.Flux<T> stream)
    Converts a flux of any type to a stream of XML documents, suitable for SSE endpoints.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EVENT_STREAM_XML_VALUE

      public static final String EVENT_STREAM_XML_VALUE
      See Also:
    • EVENT_STREAM_XML

      public static final org.springframework.http.MediaType EVENT_STREAM_XML
  • Constructor Details

  • Method Details

    • toXml

      public <T> org.springframework.http.ResponseEntity<reactor.core.publisher.Flux<String>> toXml(reactor.core.publisher.Flux<T> stream)
      Converts a flux of any type to a stream of XML documents, suitable for SSE endpoints. It changes the Content-Type-Header to text/event-stream, since otherwise clients are not able to receive any events. Drops objects that cannot be serialized to an XML document.
      Type Parameters:
      T - the type of the source of the events
      Parameters:
      stream - the source for the events
      Returns:
      a stream of XML documents
    • toJson

      public <T> org.springframework.http.ResponseEntity<reactor.core.publisher.Flux<T>> toJson(reactor.core.publisher.Flux<T> stream)