Adding a reference to a Message Mapper for the Gateway proxy might be a good idea. However, before opening an issue for that, I want to suggest an alternative. You could add a <transformer/> element that converts the User payload to a String. Something like this...
Refactored gateway invocation:
Code:
public void onChange(User pUser) {
getUserChangeGateway().sendUserChange(pUser);
}
Newly separated transformation logic:
Code:
public String serializeUser(User pUser) {
return userSerializer.asString(pUser);
}
Modified config:
Code:
<gateway id="userChangeGateway"
service-interface="mycompany.domain.UserChangeGateway"
default-request-channel="userChangesChannel"
/>
<transformer input-channel="userChangesChannel"
ref="userSerializer"
method="serializeUser"
output-channel="serializedUserChangesChannel"
/>
At least this provides a workaround, but it may be a cleaner long term solution anyways depending on your overall use-cases. For example, this would allow you to intercept Messages that still have the User object as payload or to later apply different transformation logic.
If you still think that setting a message-mapper directly on the gateway proxy would be a better solution, then please create an issue in JIRA. Hopefully the suggestion here would work as a decent workaround in the meantime.
Let me know what you think.