121.5. 複数のタイプのイベントの使用
Guava EventBus コンシューマーが使用する複数のタイプのイベントを定義するには、listenerInterface
エンドポイントオプションを使用します。リスナーインターフェースは、@Subscribe
アノテーションでマークされた複数のメソッドを提供できます。
package com.example; public interface MultipleEventsListener { @Subscribe void someEventReceived(SomeEvent event); @Subscribe void anotherEventReceived(AnotherEvent event); }
package com.example;
public interface MultipleEventsListener {
@Subscribe
void someEventReceived(SomeEvent event);
@Subscribe
void anotherEventReceived(AnotherEvent event);
}
上記のリスナーは、以下のようにエンドポイント定義で使用できます。
from("guava-eventbus:busName?listenerInterface=com.example.MultipleEventsListener").to("seda:queue");
from("guava-eventbus:busName?listenerInterface=com.example.MultipleEventsListener").to("seda:queue");