Now I have a RSocket controller as following:

@Controller
@MessageMapping("org.xxx.account.AccountService")
public class AccountRSocketController {
    @Autowired
    private AccountService accountService;

    @MessageMapping("findById")
    public Mono<Account> findById(Integer id) {
        return accountService.findById(id);
    }
}

I don't want to write method name as @MessageMapping's value for each method handler, some complicated and not good for method rename. Is it possible to make @MessageMapping to use method name as default value like following code.

    @MessageMapping
    public Mono<Account> findById(Integer id) {
        return accountService.findById(id);
    }

I checked MessageMappingMessageHandler.java, and any possible to pass method's name to getCondition(method) and use method name as default value for @MessageMapping?

@Override
    protected CompositeMessageCondition getMappingForMethod(Method method, Class<?> handlerType) {
        CompositeMessageCondition methodCondition = getCondition(method);
        if (methodCondition != null) {
            CompositeMessageCondition typeCondition = getCondition(handlerType);
            if (typeCondition != null) {
                return typeCondition.combine(methodCondition);
            }
        }
        return methodCondition;
    }

Comment From: rstoyanchev

I think we could do that but it would probably need to be enabled through a property on RSocketMessageHandler or otherwise it could change the mapping for some existing methods that don't expect this.

Comment From: rstoyanchev

This is how it can be done today:

static class MyRSocketMessageHandler extends RSocketMessageHandler {

    @Override
    protected CompositeMessageCondition getMappingForMethod(Method method, Class<?> handlerType) {
        return new CompositeMessageCondition(
                new DestinationPatternsMessageCondition(
                        new String[] {handlerType.getName() + "." + method.getName()},
                        obtainRouteMatcher()));
    }
}

We could add a property to enable the above:

rsocketMessageHandler.setUseClassnameConvention(true);

But it would have to be more flexible probably:

rsocketMessageHandler.setUseClassnameConvention(method -> 
        method.getDeclaringClass().getSimpleName() + "." + method.getName());

So this is possible, but such a property doesn't save much code.

Thinking more about the motivation. This makes it convenient for server code but clients have to know server class/method names which isn't very nice and it is also brittle. Any refactoring of class or method names will change the routes.

In the end it's better to use logical routes that don't have to follow or be the same as class/method names, e.g. "accounts.{id}" rather than "AccountRSocketController.findById" or even "org.xxx.account.AccountRSocketController.findById". That's shorter and nicer for clients to use, and is not impacted by refactoring. It allows patterns and variables too.

In light of this, I don't think we'll add a built-in option to the framework, but it is still very easy to achieve through the example above.