0

I am using Spring Cloud Bus (1.2.1.RELEASE, Camden.SR2). I have a custom event (call it CustomEvent) that I have created and registered via @RemoteApplicationEventScan as well as a custom AbstractBusEndpoint implementation to publish the event. I am able to publish events to the bus just fine.

My remote application receives the event and acknowledges (I verified this using the trace endpoint). I have verified via debugging that the CustomEvent is published via the ApplicationEventPublisher provided in BusAutoConfiguration#acceptRemote. I have a bean with an event handler in my remote application (I have this auto-configured into all of my micro-services):

@Component
public class EventListener {

  @EventHandler(CustomEvent.class)
  public void handleCustomEvent(CustomEvent event) {
    ..
  }
}

Despite this, the event handler will not receive the event. I traced within the AbstractApplicationEventMulticaster class and despite my bean being created (verified via beans endpoint), the listener is not in the list of ApplicationListeners retrieved by ListenerRetriever. I do see the BusAutoConfiguration.acceptLocal listener in this list, but not my custom listener.

This event handler is also registered on the source application (the one I am accessing the bus endpoint from to initiate the event). The custom listener receives the event in this application, but not the remote application.

Essentially, both applications are configured the exact same except one is configured to send the CustomEvent using an implementation of AbstractBusEndpoint.

I am out of ideas of where else to look within the Spring code to debug this problem. If anyone has a thread they can lead me on it would be appreciated.

SteveO
  • 399
  • 2
  • 12
  • I'll take a look this week now that I'm back from holiday. – spencergibb Jan 09 '17 at 17:10
  • sorry for the delay. I created a sample application `Camden.SR6` and a custom event, endpoint and listener as you described and everything seems to work. Can you verify? – spencergibb Apr 05 '17 at 23:40
  • Hi Spencer. I can confirm this problem no longer exists once we upgraded to Camden.SR6. Thanks for looking into this. – SteveO Apr 14 '17 at 12:49

1 Answers1

0

I've come up with the exact same problem, and debugging it revealed that ApplicationListener which handles the custom remote event not returned among candidate listeners within ApplicationEventMulticaster due to eventType was loaded by two different classloaders, one of them was devtools related classloader. Removing devtools dependency from classpath simply resolved issue for me.

ksevindik
  • 59
  • 3