fix(server): start event bus processor for manual wiring#997
Open
014-code wants to merge 1 commit into
Open
Conversation
Ensure MainEventBusProcessor.ensureStarted() starts manually constructed processors, and call it from DefaultRequestHandler.create(...). This prevents manually wired integrations from leaving events stuck on the main event bus. Add a regression test for the manual wiring path that returns a Message response. This fixes a2aproject#995
|
Based on the summary in #997, I adjusted the way Spring beans are constructed in The change are:
In other words, the following construct @Bean
public RequestHandler requestHandler(AgentExecutor agentExecutor, TaskStore taskStore, QueueManager queueManager,
PushNotificationConfigStore pushConfigStore,
MainEventBus mainEventBus,
PushNotificationSender pushSender,
@Qualifier("a2aInternal") Executor executor) {
ExecutorService eventConsumerExecutor = Executors.newFixedThreadPool(3);
return new DefaultRequestHandler(agentExecutor, taskStore, queueManager, pushConfigStore,
new MainEventBusProcessor(mainEventBus, taskStore, pushSender, queueManager),
executor,
eventConsumerExecutor);
}is transformed into @Bean
public MainEventBusProcessor mainEventBusProcessor(MainEventBus mainEventBus,TaskStore taskStore,
PushNotificationSender pushSender,
QueueManager queueManager) {
return new MainEventBusProcessor(mainEventBus, taskStore, pushSender, queueManager);
}
@Bean
public RequestHandler requestHandler(AgentExecutor agentExecutor, TaskStore taskStore, QueueManager queueManager,
PushNotificationConfigStore pushConfigStore,
MainEventBusProcessor mainEventBusProcessor,
@Qualifier("a2aInternal") Executor executor) {
return new DefaultRequestHandler(agentExecutor, taskStore, queueManager,
pushConfigStore, mainEventBusProcessor,
executor, executor);
}Spring Boot recognizes Then, test using the following request: {
"jsonrpc": "2.0",
"id": "6e7bf51a-f364-42d7-a060-343da3cc4f43",
"method": "SendMessage",
"params": {
"message": {
"messageId": "messageId-1",
"role": "ROLE_USER",
"parts": [
{
"text": "Can you check systems?"
}
]
}
}
}Response Response Body: {
"error": null,
"id": "6e7bf51a-f364-42d7-a060-343da3cc4f43",
"jsonrpc": "2.0",
"result": {
"role": "ROLE_AGENT",
"parts": [
{
"text": "Hello World",
"metadata": null
}
],
"messageId": "d062faba-39e6-4ac6-b891-9e0ba1363a69",
"contextId": "c2c16e07-dfad-40f1-958c-41d336d4363e",
"taskId": "d38c2bc5-7491-4920-a290-93582d21a9e0",
"referenceTaskIds": null,
"metadata": null,
"extensions": null
}
}That is, a success result was returned. Hopefully, these new improvements will be helpful to your revisions. Thanks for what you did. |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MainEventBusProcessorinstances are started throughensureStarted().ensureStarted()fromDefaultRequestHandler.create(...)so Spring/manual wiring paths do not leave events stuck onMainEventBus.Messageresponse.Related Issue
This fixes #995.
Testing
mvn -pl server-common -am -Dtest=DefaultRequestHandlerTest#testCreateStartsManuallyConstructedMainEventBusProcessor -Dsurefire.failIfNoSpecifiedTests=false test