How does a Java event occur, namely javax.enterprise.event.fire ()?

I have the following situation (works on JBoss AS6 and AS7):

  • An Singleton EJB with a scheduled method.
  • Type event entered SomethingChangedEvent

Consider the following examples:

@Singleton
public final class Scheduler {
    @Inject
    private Event<SomethingChangedEvent> event;

    @Schedule
    private void scheduleSomething() {
        event.fire(new SomethingChangedEvent());
    }
}

I expect this event to be added to some queue on the server and distributed by it. Any methods for observing this type of event with will be notified @Observers. The method event.fire()will return immediately.

However, I encounter the following problem: sometimes the method event.fire()returns two or three minutes to cause chaos in my schedule, since it is assumed that it is called once every ten seconds.

, : ? , , ? , ?

,

+5
1

CDI . , , - . "" :

:

@Singleton
public final class Scheduler {
    @Inject
    private Event<SomethingChangedEvent> event;

    @Asynchronous
    private void scheduleSomething() {
        event.fire(new SomethingChangedEvent());
    }
}
+6

All Articles