Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow @SendToUser applied to class [SPR-12047] #16663

Closed
spring-projects-issues opened this issue Jul 30, 2014 · 5 comments
Closed

Allow @SendToUser applied to class [SPR-12047] #16663

spring-projects-issues opened this issue Jul 30, 2014 · 5 comments
Assignees
Labels
in: messaging Issues in messaging modules (jms, messaging) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Alex opened SPR-12047 and commented

When implementing an RPC pattern over STOMP we have to apply the @SendToUser annotation to every method.

It would be useful to have the possibility to annotate the class so that every method annotated with @MessageMapping is automatically annotated with the corresponding @SendToUser, in a similar way to what @RestController does.


Affects: 4.0.6

Referenced from: commits 03e3ef5

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

I can't imagine a good name (like @RestController) here. Also unlike @ResponseBody, an @SendToUser annotation has attributes. Perhaps we can achieve the same effect by supporting @SendToUser on the type level. Such an annotation on the type level could be used also to share a common prefix for the reply destination, or to set broadcast=false.

@spring-projects-issues
Copy link
Collaborator Author

Alex commented

Something like that would be ideal for me:

@RpcMessagingController(value="/queue/replies", errors="/queue/errors", messageId="myId")
public class MessagingController {

  @MessageMapping("/my/method1")
  public Object method1(MyObject input) {
    ...
    return object;
  }

  @MessageExceptionHandler
  public Object handleException(MethodArgumentNotValidException e) {
    ...
    return object;
  }

}

The meaning of the @RpcMessagingController annotation would be this one:

  • consider every method annotated with @MessageMapping implicitly as @SendToUser("/queue/replies")
  • consider every method annotated with @MessageExceptionHandler implicitly as @SendToUser("/queue/errors")
  • automatically extract the "myId" attribute from native headers of the incoming message and put it on the message reply headers (both for normal messages and exceptions

The latter point is the key one, the one that enables a client to map every rpc call with the correct reply, or to correctly handle timeouts.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jul 31, 2014

Alex commented

Related to this issue: #16664

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

First we'll make this original request for this ticket work and we'll do that by adding support for @SendToUser on the class level. That's a very natural extension of what we already have.

The copying of headers needs to be considered on its own. It is an additional feature request and affects more than just @SendToUser. Feel free to create a separate ticket for that.

As for @RpcMessagingController we can add support for detecting type-level @SendTo/@SendToUser annotations in SendToMethodReturnValueHandler, which is exactly what we do for @ResponseBody. You can then create your own @RpcMessagingController meta-annotation, annotated with @SendToUser (see @RestController for example).

@spring-projects-issues
Copy link
Collaborator Author

Alex commented

I've proposed a working solution (albeit not general enough to be included in Spring as-is) for the third point here: https://jira.spring.io/browse/SPR-12048?focusedCommentId=106517&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-106517

I suppose there is no need to open another ticket but please advise the way you prefer me to proceed.

@spring-projects-issues spring-projects-issues added in: messaging Issues in messaging modules (jms, messaging) type: enhancement A general enhancement labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.3 RC1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants