use of org.springframework.integration.annotation.ServiceActivator in project spring-integration-samples by spring-projects.
the class Application method handler.
@ServiceActivator(inputChannel = "toKafka")
@Bean
public MessageHandler handler(KafkaTemplate<String, String> kafkaTemplate) {
KafkaProducerMessageHandler<String, String> handler = new KafkaProducerMessageHandler<>(kafkaTemplate);
handler.setMessageKeyExpression(new LiteralExpression(this.properties.getMessageKey()));
return handler;
}
use of org.springframework.integration.annotation.ServiceActivator in project spring-integration-samples by spring-projects.
the class Application method loggingChannelAdapter.
@Bean
@ServiceActivator(inputChannel = "sendTimeChannel")
public MessageHandler loggingChannelAdapter() {
LoggingHandler loggingHandler = new LoggingHandler("info");
loggingHandler.setLogExpressionString("'The time ' + payload + ' has been sent to the WebSocketSession ' + headers.simpSessionId");
return loggingHandler;
}
use of org.springframework.integration.annotation.ServiceActivator in project spring-integration-samples by spring-projects.
the class Application method twitterGate.
@Bean
@ServiceActivator(inputChannel = "searchChannel")
public TwitterSearchOutboundGateway twitterGate() {
TwitterSearchOutboundGateway gateway = new TwitterSearchOutboundGateway(twitter());
gateway.setOutputChannel(toJsonChannel());
return gateway;
}
use of org.springframework.integration.annotation.ServiceActivator in project microservices by pwillhan.
the class MailService method sendMailAlert.
@ServiceActivator(inputChannel = "notifyChannel")
public void sendMailAlert(String body) {
String[] parts = body.split("\\|");
String email = parts[0];
String realbody = parts[1];
logger.info("MailService : " + body);
SimpleMailMessage msg = new SimpleMailMessage();
msg.setTo(email);
msg.setFrom(env.getProperty("com.cassandrawebtrader.mail.from"));
msg.setSubject(env.getProperty("com.cassandrawebtrader.mail.subject"));
msg.setText(realbody);
try {
mailSender.send(msg);
logger.info(msg.toString());
} catch (MailException e) {
logger.error(e.getMessage());
}
}
use of org.springframework.integration.annotation.ServiceActivator in project faf-java-server by FAForever.
the class LegacyServicesActivators method loginRequest.
@ServiceActivator(inputChannel = ChannelNames.LEGACY_LOGIN_REQUEST)
@Transactional
public void loginRequest(LegacyLoginRequest loginRequest, @Header(CLIENT_CONNECTION) ClientConnection clientConnection) {
// TODO this method shouldn't do anything but call a service
Requests.verify(!playerService.isPlayerOnline(loginRequest.getLogin()), ErrorCode.USER_ALREADY_CONNECTED, loginRequest.getLogin());
log.debug("Processing login request from user: {}", loginRequest.getLogin());
try {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(loginRequest.getLogin(), loginRequest.getPassword());
Authentication authentication = authenticationManager.authenticate(token);
FafUserDetails userDetails = (FafUserDetails) authentication.getPrincipal();
clientConnection.setAuthentication(authentication);
Player player = userDetails.getPlayer();
player.setClientConnection(clientConnection);
geoIpService.lookupCountryCode(clientConnection.getClientAddress()).ifPresent(player::setCountry);
uniqueIdService.verify(player, loginRequest.getUniqueId());
chatService.updateIrcPassword(userDetails.getUsername(), loginRequest.getPassword());
playerService.setPlayerOnline(player);
} catch (BadCredentialsException e) {
throw new RequestException(e, ErrorCode.INVALID_LOGIN);
}
}
Aggregations