Search in sources :

Example 6 with ServiceActivator

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;
}
Also used : LiteralExpression(org.springframework.expression.common.LiteralExpression) KafkaProducerMessageHandler(org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler) ServiceActivator(org.springframework.integration.annotation.ServiceActivator) Bean(org.springframework.context.annotation.Bean)

Example 7 with ServiceActivator

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;
}
Also used : LoggingHandler(org.springframework.integration.handler.LoggingHandler) ServiceActivator(org.springframework.integration.annotation.ServiceActivator) Bean(org.springframework.context.annotation.Bean)

Example 8 with ServiceActivator

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;
}
Also used : TwitterSearchOutboundGateway(org.springframework.integration.twitter.outbound.TwitterSearchOutboundGateway) ServiceActivator(org.springframework.integration.annotation.ServiceActivator) Bean(org.springframework.context.annotation.Bean)

Example 9 with ServiceActivator

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());
    }
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) MailException(org.springframework.mail.MailException) ServiceActivator(org.springframework.integration.annotation.ServiceActivator)

Example 10 with ServiceActivator

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);
    }
}
Also used : Player(com.faforever.server.entity.Player) Authentication(org.springframework.security.core.Authentication) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) FafUserDetails(com.faforever.server.security.FafUserDetails) BadCredentialsException(org.springframework.security.authentication.BadCredentialsException) RequestException(com.faforever.server.error.RequestException) ServiceActivator(org.springframework.integration.annotation.ServiceActivator) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ServiceActivator (org.springframework.integration.annotation.ServiceActivator)12 Bean (org.springframework.context.annotation.Bean)7 FileInputStream (java.io.FileInputStream)2 Span (brave.Span)1 Tracer (brave.Tracer)1 Player (com.faforever.server.entity.Player)1 RequestException (com.faforever.server.error.RequestException)1 FafUserDetails (com.faforever.server.security.FafUserDetails)1 File (java.io.File)1 PubSubMessageHandler (org.springframework.cloud.gcp.pubsub.integration.outbound.PubSubMessageHandler)1 LiteralExpression (org.springframework.expression.common.LiteralExpression)1 FileWritingMessageHandler (org.springframework.integration.file.FileWritingMessageHandler)1 LoggingHandler (org.springframework.integration.handler.LoggingHandler)1 KafkaProducerMessageHandler (org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler)1 MqttPahoMessageHandler (org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler)1 DefaultMessageSplitter (org.springframework.integration.splitter.DefaultMessageSplitter)1 TwitterSearchOutboundGateway (org.springframework.integration.twitter.outbound.TwitterSearchOutboundGateway)1 MailException (org.springframework.mail.MailException)1 SimpleMailMessage (org.springframework.mail.SimpleMailMessage)1 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)1