EventBus is not instantiating

Hi,

As per https://github.com/marinkobabic/axon-kafka-example, I have followed the almost same implementation to use Kafka to publish events.
I have upgraded my dependencies as below

implementation("org.axonframework.extensions.kafka:axon-kafka:4.0-RC2")
implementation group: 'org.axonframework', name: 'axon-spring-boot-starter', version: '4.2'

I am not able to autowire the eventbus , it is giving Nullpointer excetion.

Note: I cannot use version as 3.X as it don't include the org.axonframework.modelling.command.TargetAggregateIdentifier.

Please suggest what i am doing wrong.

Hi Samrat,

could you share the stacktrace? They’re likely to hold essential information about the issue you’re facing.

Including the axon-spring-boot-starter should give you an EventStore or EventBus, depending on the other dependencies available. Since EventStore extends EventBus, wiring the EventBus should just work.

Cheers,

@Component
@Slf4j
public class KafkaSender {

    @Autowired
    private EventBus eventBus;

    <T> void send(T event) {
        log.info("Event Publish"+event);
        EventMessage<T> eventMessage = GenericEventMessage.asEventMessage(event);
        eventBus.publish(eventMessage);//Nullpointer Exception

    }

}

@Allard Buijze Can you look into the post and respond ? I have shared my snippet for the eventbus and it is not instantiating as default even after including the dependency.

Hi All
I have resolved my issue. I was following the example shown in the git repo. But for release for 4.X, it is not required we can directly use AggregateLifecycle.apply