I want to send an email once an SFTP upload is completed ...
I have an SFTP uploader:
<sftp:outbound-channel-adapter
id="sftpOutboundAdapter"
channel="inputFiles"
charset="UTF-8"
remote-directory="${directory.remote}"
session-factory="sftpSessionFactory">
<sftp:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<property name="onSuccessExpression" value="payload.delete()"/>
<property name="successChannel" ref="successChannel"/>
<property name="onFailureExpression" value="payload.renameTo(payload.absolutePath + '.error')"/>
<property name="failureChannel" ref="failChannel"/>
</bean>
</sftp:request-handler-advice-chain>
</sftp:outbound-channel-adapter>
Which sends the payload to the successChannel once it's done:
<int:channel id="successChannel">
<int:interceptors>
<int:wire-tap channel="successLogChannel"/>
</int:interceptors>
</int:channel>
... which then logs it thanks to a wiretap.
<int:channel id="successLogChannel"/>
<int:transformer input-channel="successLogChannel" output-channel="logChannel"
expression="'Successfully transferred ' + inputMessage.payload.absolutePath + ' [result=' + payload + ']'"/>
<int:logging-channel-adapter id="logChannel" level="INFO"/>
And here is where it's breaking, I don't think properties is the right element to use, I basically need to break out into a java class and be able to pass in parameters including the name of the file I just uploaded.
<int:service-activator input-channel="successChannel" ref="Email" method="sendSuccessMail">
<property name="to" value="test@gmail.com" />
<property name="from" value="me@me.com" />
<property name="filename" ref="'inputMessage.payload.absolutePath'" />
</int:service-activator>
Java Class:
@Component(value = "Email")
public class Email extends AbstractMessaging<EmailRequest, EmailResponse> {
....
public void sendSuccessMail(String to, String from, String filename){
log.info("--------------------------------------------");
log.info("Success Mail will be sent here to" + to + ", from " + from + " for " + filename);
log.info("--------------------------------------------");
}
}
FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Target object of type [class ... .email.Email] has no eligible methods for handling Messages.
Is it possible to pass params or just the payload if I can't params to my method sendSuccessMail
?