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.
Solved! Go to Solution.
Views
Replies
Total Likes
If you look at your code, you can see that you're explicitly declaring this component as a "BiosFactory" service, not an EventHandler.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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]
Views
Replies
Total Likes
... 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.
Views
Replies
Total Likes
If you look at your code, you can see that you're explicitly declaring this component as a "BiosFactory" service, not an EventHandler.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes