Spring Cloud Stream Supplier function model

Viewed 500

I am trying to use spring cloud stream and the new functions support for configuration but I am having a problem to understand how to achieve the same result I would have with annotation configuration.

I need to send a message to the brooker, every time a user is created. With the annotation based configuration I could accomplish it like this:

 public UserProducer {
    
    @Autowired
    private final Source source;
    
    @Autowired
    private final UserRepository repository;

    public void saveUser(User user) {
        repository.save(user);
        source.output().send(MessageBuilder.withPayload(user).build());
    }
 }

Is it possible to use spring cloud stream functions to achieve the same result?

1 Answers
Related