Skip to content

RSocket Metadata Mimetype "text/plain" and "application/json" support #23157

Closed
@linux-china

Description

@linux-china

Now RSocket adopts "message/x.rsocket.composite-metadata.v0" and "message/x.rsocket.routing.v0" as metadata MimeType. Please consider add "text/plain" as metadata Mime type, some cases, the text just as route key. If possible, could "application/json" be added as metadata Mime type and routing key is "routing" field like following:

{
  "routing": "chat_room",
  ....
}

Both "text/plain" and "application/json" are friendly and easy for Javascript in browser.

https://github.com/spring-projects/spring-framework/blob/master/spring-messaging/src/main/java/org/springframework/messaging/rsocket/MessagingRSocket.java

private String getDestination(Payload payload) {
		if (this.metadataMimeType.equals(DefaultRSocketRequester.COMPOSITE_METADATA)) {
			CompositeMetadata metadata = new CompositeMetadata(payload.metadata(), false);
			for (CompositeMetadata.Entry entry : metadata) {
				String mimeType = entry.getMimeType();
				if (DefaultRSocketRequester.ROUTING.toString().equals(mimeType)) {
					return entry.getContent().toString(StandardCharsets.UTF_8);
				}
			}
			return "";
		}
		else if (this.metadataMimeType.equals(DefaultRSocketRequester.ROUTING)) {
			return payload.getMetadataUtf8();
		}
		// Should not happen (given constructor assertions)
		throw new IllegalArgumentException("Unexpected metadataMimeType");
	}

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions