Skip to content

Event Propagation Example using Spring

David Fuelling edited this page May 23, 2019 · 1 revision

Overview

The Java Connector relies upon a Guava EventBus for all "event" propagations in the runtime (i.e., events are propagated only inside of the JVM to any registered listeners).

However, Spring also has an event system. Though it is currently unused in the Connector, this page provides an example of how it might work:

Example

  /**
     * If an AccountManager is present in the system running this routing service, then this service can react to those
     * events by updating the routing table.
     *
     * @param accountAddedEvent
     */
    @EventListener(condition = "#event.name == T(com.sappenin.interledger.ilpv4.connector.events.AccountAddedEvent).NAME")
    public void handleAccountAdded(AccountAddedEvent accountAddedEvent) {


    }

    /**
     * If an AccountManager is present in the system running this routing service, then this service can react to those
     * events by updating the routing table.
     *
     * @param accountRemovedEvent
     */
    @EventListener(
      condition = "#event.name == T(com.sappenin.interledger.ilpv4.connector.events.AccountRemotedEvent).NAME"
    )
    public void handleAccountRemoved(AccountRemovedEvent accountRemovedEvent) {
      System.out.println("Handling generic event (conditional).");
    }
Clone this wiki locally