Skip to content

Support Flux<ServerSentEvent<Fragment>> in WebFlux #33975

Closed
@dsyer

Description

@dsyer

In Spring 6.2 we got a new WebFlux feature with Fragment and you can render an SSE like this:

@GetMapping(path = "/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<Fragment> stream() {
	return Flux.interval(Duration.ofSeconds(5))
			.map(value -> Fragment.create("time", Map.of("value", value, "time", System.currentTimeMillis())));
}

The only potential problem is that it doen't give you control over the SSE fields (in particular the "event" name which is unconditionaly rendered as the view name). If we could send Flux<ServerSentEvent<Fragment>> it would give us more control.

Same for MVC, but I think that might already be supported (Flux<ServerSentEvent<ModelAndView>>)?

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions