Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get events from EventBus in nexus oss 3? #516

Open
Meeki1l opened this issue Nov 18, 2024 · 0 comments
Open

How to get events from EventBus in nexus oss 3? #516

Meeki1l opened this issue Nov 18, 2024 · 0 comments
Assignees
Labels

Comments

@Meeki1l
Copy link

Meeki1l commented Nov 18, 2024

Version
Sonatype Nexus Repository OSS 3.74.0-05

Question
Hi, How do I connect to the event bus in the plugin? I am writing a plugin and I want to listen to all events in nexus. To begin with, I wrote a very simple class:

import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.nexus.common.event.Event;
import org.sonatype.nexus.common.event.EventAware;
import org.sonatype.nexus.common.event.EventManager;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

@Named
@Singleton
public class AgentHandler implements EventAware {
    private static final Logger LOG = LoggerFactory.getLogger(AgentHandler.class);
    private EventManager eventManager;

    @Inject
    public AgentHandler(final @Nonnull EventManager eventManager) {
        this.eventManager = checkNotNull(eventManager);
        eventManager.register(this);

        LOG.info("Register handler?");
    }

    @AllowConcurrentEvents
    @Subscribe
    public void onNewEvent(final Event event) {
        LOG.info("NEW Event");
    }
}

I could not find information about the reason why it does not receive events. I build the bundle and copy it to the nexus/deploy folder and restart the nexus. After that, I see in the logs that the plugin is loaded, but it does not catch new events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants