I am trying to invoke processMessage
method from my As2MessageHandler
class as my entry point into spring integration using a custom inbound-channel-adapter. But I keep getting this error saying it can't find the method when it is clearly in the class:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'as2.source': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: no such method 'processMessage' is available on class com.as2example.myexample.handler.As2MessageHandler
as2MessageHandler class:
@Component
public class As2MessageHandler extends AbstractProcessorModule implements IProcessorStorageModule {
private static final Logger LOGGER = LoggerFactory.getLogger(As2MessageHandler.class);
@Override
public boolean canHandle(@Nonnull String s, @Nonnull IMessage iMessage, @Nullable Map<String, Object> map) {
LOGGER.info(" Handle Info:" + s);
return s.equals(DO_STORE);
}
@Override
public void handle(@Nonnull String s, @Nonnull IMessage iMessage, @Nullable Map<String, Object> map) throws AS2Exception {
LOGGER.info("----- AS2 MESSAGE RECEIVED !!! ------");
LOGGER.info(iMessage.getContentType());
LOGGER.info(iMessage.getContentDisposition());
LOGGER.info(iMessage.getAsString());
processMessage(iMessage);
}
public String processMessage(IMessage message) {
LOGGER.info("BEGIN PROCESSING MESSAGE");
return message.getAsString();
}
}
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"
xmlns:context="http://www.springframework.org/schema/context"
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">
<int:channel id="as2MessageChannel">
<int:interceptors>
<int:wire-tap channel="logger"/>
</int:interceptors>
</int:channel>
<int:logging-channel-adapter id="logger" level="DEBUG"/>
<int:inbound-channel-adapter id="as2" ref="as2MessageHandler" method="processMessage" channel="as2MessageChannel">
</int:inbound-channel-adapter>
<int:service-activator input-channel="as2MessageChannel" ref="orderServiceImpl" auto-startup="true"/>
</beans>
MyApplication class:
@SpringBootApplication
@ImportResource("classpath:/integration/integration.xml")
public class MyApplication implements ServletContextListener {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
@Override
public void contextDestroyed (final ServletContextEvent sce)
{
ServletConfig.shutDown ();
AS2WebAppListener.staticDestroy ();
}
}
Can anyone provide insight into why spring integration is not recognizing the processMethod from the As2MessageHandler class? I've tried changing the method to use messagebuilder and return a Message type but that wasn't the issue. Now I'm thinking it has to be something else.
The error is correct. It might mislead a little bit since the signature of the method is wrong, not its presence. So, since an inbound channel adapter is a beginning of the flow, there really cannot be any input to the method to produce data for messages. Therefore it is not clear what is your expectation with that IMessage
as an input for the method.
It is not clear what is your design, but the POJO method in the <int:inbound-channel-adapter>
is invoked by the poller as a source of data for the message. In other words the POJO method as a source must not have arguments - only return. That's why that exception is thrown.
I don't see anything in your As2MessageHandler
which could server as a source for messages in the inbound channel adapter. This one looks more like a service activator. Please, revise your design in favor of something else what really may be used as a source of data in that AS2 protocol.