この会話は、活動がないためロックされています。新しい投稿を作成してください。
この会話は、活動がないためロックされています。新しい投稿を作成してください。
Hi,
I'm trying to post events and have them handled by a couple of services. I'm using the EventAdmin class to post send the event. The topic I use is just a string.
My handlers implement EventHandler and its handleEvent method. I also define the Property annotation, with "event.topics" set to the same topic string used to post the events. But nothing is ever received.
Do I need to create/configure queues somewhere? Does the topic name absolutely needs to be a FQCN?
Thanx.
解決済! 解決策の投稿を見る。
表示
返信
いいね!の合計
If you look at your code, you can see that you're explicitly declaring this component as a "BiosFactory" service, not an EventHandler.
表示
返信
いいね!の合計
Look at sample implementation at /apps/geometrixx/src/impl/src/main/java/com/day/cq/wcm/apps/geometrixx/impl/PageEventListener.java
If you do not configure queue use the default one. You can configure it from felix console.
表示
返信
いいね!の合計
I'm confused because I do not understand, I'm doing (at least I think I'm doing) exactly what's in the example. 3 key points:
1. posting the event in a servlet:
eventAdmin.sendEvent(new Event("com/mycomp/corpo/MOVE", properties));
2. implemented a handler:
@Component(immediate = true) @Service(value = BiosFactory.class) @Property(name = EventConstants.EVENT_TOPIC, value = { "com/mycomp/corpo/MOVE", "com/mycomp/corpo/DELETE" }) public class BiosFactoryImpl extends BaseServiceImpl implements BiosFactory, EventHandler { // ... @Override public void handleEvent(Event event) { logger.debug("Handling my event"); } }
3. Configured a queue in the OSGi admin console
[img]Adobe_CQ_Web_Console_-_Configuration-4.png[/img]
表示
返信
いいね!の合計
... and I checked in the OSGi console 'Events' applet to see if my event have been posted, and it's there. So I think it's something I'm doing wrong with the listener.
表示
返信
いいね!の合計
If you look at your code, you can see that you're explicitly declaring this component as a "BiosFactory" service, not an EventHandler.
表示
返信
いいね!の合計
yeah, got it. so by leaving the annotation empty, it seem to recognize all the declared interfaces on the class.
Or use the multiple services annotation:
@Component(immediate = true) @Services(value = { @Service(value = BiosFactory.class), @Service(value = EventHandler.class) }) @Property(name = EventConstants.EVENT_TOPIC, value = { "com/mycomp/corpo/MOVE", "com/mycomp/corpo/DELETE" }) public class BiosFactoryImpl extends BaseServiceImpl implements BiosFactory, EventHandler { // ... @Override public void handleEvent(Event event) { logger.debug("Handling my event"); } }
thank you.
表示
返信
いいね!の合計