Search in sources :

Example 11 with ServiceActivator

use of org.springframework.integration.annotation.ServiceActivator in project tutorials by eugenp.

the class FileCopyConfig method fileWritingMessageHandler.

@Bean
@ServiceActivator(inputChannel = "fileChannel")
public MessageHandler fileWritingMessageHandler() {
    FileWritingMessageHandler handler = new FileWritingMessageHandler(new File(OUTPUT_DIR));
    handler.setFileExistsMode(FileExistsMode.REPLACE);
    handler.setExpectReply(false);
    return handler;
}
Also used : FileWritingMessageHandler(org.springframework.integration.file.FileWritingMessageHandler) File(java.io.File) ServiceActivator(org.springframework.integration.annotation.ServiceActivator) Bean(org.springframework.context.annotation.Bean)

Example 12 with ServiceActivator

use of org.springframework.integration.annotation.ServiceActivator in project brewery by spring-cloud-samples.

the class EventListener method handleEvents.

@ServiceActivator(inputChannel = EventSink.INPUT)
public void handleEvents(Event event, @Headers Map<String, Object> headers) throws InterruptedException {
    log.info("Received the following message with headers [{}] and body [{}]", headers, event);
    Span newSpan = tracer.nextSpan().name("inside_reporting").start();
    try (Tracer.SpanInScope ws = tracer.withSpanInScope(newSpan)) {
        reportingRepository.createOrUpdate(event);
        newSpan.annotate("savedEvent");
        log.info("Saved event to the db", headers, event);
    } finally {
        newSpan.finish();
    }
}
Also used : Tracer(brave.Tracer) Span(brave.Span) ServiceActivator(org.springframework.integration.annotation.ServiceActivator)

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