How to use Spring Integration to receive message in service layer?

I would like to ask questions about spring Integration with MQTT After reading the documents on the official website

I successfully received the message from the MQTT broker, like this:

@SpringBootApplication
public class MqttJavaApplication {

public static void main(String[] args) {
    new SpringApplicationBuilder(MqttJavaApplication.class)
            .web(false)
            .run(args);
}

@Bean
public MessageChannel mqttInputChannel() {
    return new DirectChannel();
}

@Bean
public MessageProducer inbound() {
    MqttPahoMessageDrivenChannelAdapter adapter =
            new MqttPahoMessageDrivenChannelAdapter("tcp://localhost:1883", "testClient",
                                             "topic1", "topic2");
    adapter.setCompletionTimeout(5000);
    adapter.setConverter(new DefaultPahoMessageConverter());
    adapter.setQos(1);
    adapter.setOutputChannel(mqttInputChannel());
    return adapter;
}

@Bean
@ServiceActivator(inputChannel = "mqttInputChannel")
public MessageHandler handler() {
    return new MessageHandler() {

        @Override
        public void handleMessage(Message<?> message) throws MessagingException {
            System.out.println(message.getPayload());
        }

    };
}

}

But this is a config file. I don't think it is a good idea to handle Message in the config file, but I have found many other MessageHandlers, such as MqttPahoMessageHandler, but I don’t know how to use it. I want to be able to process these messages in the Service layer.