query regarding e-mail outbound-channel-adapter...!!!
Hi,
I am developing an application which is use to send the message of a channel as a email, let say that a particular
message inside the channel will be mailed to anyone on his gmail id .The e-mail outbound-channel-adapter uses the SMTP protocol to send e-mail messages,For that I have an application but now I want that it annotation based configuration should be removed and all these setting should be there in the configuration file itself
, no annotation is to be there in the application...the annotations used below are ...
MailConfiguration.java
*******************************
Code:
@Configuration
public class MailConfiguration {
@Bean
public JavaMailSenderImpl mailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("smtp.gmail.com");
mailSender.setPort(587);
mailSender.setUsername("[username]");
mailSender.setPassword("[password]");
Properties properties = new Properties();
properties.setProperty("mail.smtp.starttls.enable", "true");
properties.setProperty("mail.smtp.auth", "true");
mailSender.setJavaMailProperties(properties);
return mailSender;
}
}
Smtp-Mail.xml
*******************
I want all these configuration in the xml file itself ,rite now I have current configuration such as ...
Code:
<?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:mail="http://www.springframework.org/schema/integration/mail"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration/mail
http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.apress.prospringintegration.social.mail"/>
<int:channel id="input"/>
<int:channel id="outboundMail"/>
<mail:outbound-channel-adapter channel="outboundMail"
mail-sender="mailSender"/>
<mail:header-enricher input-channel="input" output-channel="outboundMail">
<mail:to value="[email]"/>
<mail:from value="[email]"/>
<mail:subject value="Test"/>
</mail:header-enricher>
</beans>
and the main file is SmtpMail.java
***************************************
Code:
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.support.MessageBuilder;
public class SmtpMail {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"/spring/mail/smtp-mail.xml", SmtpMail.class);
MessageChannel input = context.getBean("input", MessageChannel.class);
Message<String> message = MessageBuilder.withPayload("This is a test").build();
input.send(message);
context.stop();
}
}
please advise me how to remove the annotations and set all the properties in the xml file itself....Thanks in advance:rolleyes: