I have the following code:
Controller:
eventNotifier.saveMessage(buildMessage(message, room, sender));
EventNotifier:
public void saveMessage(Message message){
r.notify(EventConsumer.NEW_MESSAGE, Event.wrap(message));
}
EventConsumer:
@PostConstruct
public void onStartUp() {
r.on(Selectors.R(MESSAGE_SAVED), createEventAndPush());
r.on(Selectors.R(NEW_MESSAGE), saveMessage());
r.on(Selectors.R(EVENT), pushToMixpanel());
}
public Consumer<Event<Message>> saveMessage(){
System.err.println("Calling save async");
return event -> messageRepo.save(event.getData());
}
turns out that the method saveMessage
is never being called. I saw it being called once, during the startup server process.
I'm not sure this is reactor-related or spring related.
edit: I moved the saving process to a service, nothing changed
edit2: I logged the service action to see what is going on:
@Service
@Slf4j
public class MessageService {
@Autowired MessageRepository messageRepo;
@Transactional
public void save(Message m){
try{
log.info("Saving...");
messageRepo.save(m);
log.info("Saved");
}catch(Exception e){
e.printStackTrace();
}
}
the output in console is:
2016-09-09 16:24:42.152 INFO 45041 --- [ wa-chub-2] com.inkdrop.app.services.MessageService : Saving...
2016-09-09 16:24:42.154 INFO 45041 --- [ wa-chub-2] com.inkdrop.app.services.MessageService : Saved
no logs from JPA, nothing!