'Spring boot integration - ref not recognizing bean for adapter
I am trying to build a spring boot project with spring integration to handle incoming as2 messages using a custom inbound-channel-adapter. for some reason the ref argument of the adapter is not finding a bean definition for my class.
I have the followed spring reference files and online resources and have the following understanding:
- Adding the
@ImportResource("/integration/integration.xml")
annotation pointing to my spring integration xml file adds it to the application context
@SpringBootApplication
@ImportResource("/integration/integration.xml")
public class MyApplication implements ServletContextListener {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
- adding the
@Component
annotation above my class should make it autodetectable as a bean by my spring boot application
@Component
public class MyHandlerModule extends AbstractProcessorModule implements IProcessorStorageModule {
private static final Logger LOGGER = LoggerFactory.getLogger(MyHandlerModule.class);
@Override
public boolean canHandle(@Nonnull String s, @Nonnull IMessage iMessage, @Nullable Map<String, Object> map) {
LOGGER.info(" Handle Info:" + s);
LOGGER.info(map.toString());
return s.equals(DO_STORE);
}
@SneakyThrows
@Override
public void handle(@Nonnull String s, @Nonnull IMessage iMessage, @Nullable Map<String, Object> map) {
LOGGER.info("----- AS2 MESSAGE RECEIVED !!! ------");
}
}
- and yet I am getting an error when running the application in my
integration.xml
file with the following message:
A component required a bean named 'com.example.MyHandlerModule' that could not be found.
For reference, here is my integration.xml
file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<int:channel id="as2MessageChannel"/>
<int:inbound-channel-adapter id="as2" ref="com.example.MyHandlerModule" method="handle" channel="as2MessageChannel"/>
</beans>
Is there something I am missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|