Search in sources :

Example 1 with ServiceActivator

use of org.springframework.integration.annotation.ServiceActivator in project spring-boot by spring-projects.

the class SampleEndpoint method hello.

@ServiceActivator
public String hello(File input) throws Exception {
    FileInputStream in = new FileInputStream(input);
    String name = new String(StreamUtils.copyToByteArray(in));
    in.close();
    return this.helloWorldService.getHelloMessage(name);
}
Also used : FileInputStream(java.io.FileInputStream) ServiceActivator(org.springframework.integration.annotation.ServiceActivator)

Example 2 with ServiceActivator

use of org.springframework.integration.annotation.ServiceActivator in project sinsim by WilsonHu.

the class MqttService method mqttOutbound.

@Bean
@ServiceActivator(inputChannel = "mqttOutboundChannel")
public MessageHandler mqttOutbound() {
    MqttPahoMessageHandler messageHandler = new MqttPahoMessageHandler("server", mqttClientFactory());
    messageHandler.setAsync(true);
    messageHandler.setDefaultTopic("/topic/client/test");
    return messageHandler;
}
Also used : MqttPahoMessageHandler(org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler) ServiceActivator(org.springframework.integration.annotation.ServiceActivator) Bean(org.springframework.context.annotation.Bean)

Example 3 with ServiceActivator

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

the class SenderApplication method messageSender.

@Bean
@ServiceActivator(inputChannel = "pubSubOutputChannel")
public MessageHandler messageSender(PubSubTemplate pubsubTemplate) {
    PubSubMessageHandler adapter = new PubSubMessageHandler(pubsubTemplate, "exampleTopic");
    adapter.setPublishCallback(new ListenableFutureCallback<String>() {

        @Override
        public void onFailure(Throwable ex) {
            LOGGER.info("There was an error sending the message.");
        }

        @Override
        public void onSuccess(String result) {
            LOGGER.info("Message was sent successfully.");
        }
    });
    return adapter;
}
Also used : PubSubMessageHandler(org.springframework.cloud.gcp.pubsub.integration.outbound.PubSubMessageHandler) ServiceActivator(org.springframework.integration.annotation.ServiceActivator) Bean(org.springframework.context.annotation.Bean)

Example 4 with ServiceActivator

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

the class Application method splitter.

@Bean
@ServiceActivator(inputChannel = "splitChannel")
public MessageHandler splitter() {
    DefaultMessageSplitter splitter = new DefaultMessageSplitter();
    splitter.setOutputChannelName("headerEnricherChannel");
    return splitter;
}
Also used : DefaultMessageSplitter(org.springframework.integration.splitter.DefaultMessageSplitter) ServiceActivator(org.springframework.integration.annotation.ServiceActivator) Bean(org.springframework.context.annotation.Bean)

Example 5 with ServiceActivator

use of org.springframework.integration.annotation.ServiceActivator in project Activiti by Activiti.

the class DemoApplication method processFile.

@ServiceActivator(inputChannel = "fileChannel")
public void processFile(Message<File> message) throws IOException {
    securityUtil.logInAs("system");
    File payload = message.getPayload();
    logger.info(">>> Processing file: " + payload.getName());
    String content = FileUtils.readFileToString(payload, "UTF-8");
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy HH:mm:ss");
    logger.info("> Processing content: " + content + " at " + formatter.format(new Date()));
    ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey("categorizeProcess").withName("Processing Content: " + content).withVariable("content", content).build());
    logger.info(">>> Created Process Instance: " + processInstance);
    logger.info(">>> Deleting processed file: " + payload.getName());
    payload.delete();
}
Also used : ProcessInstance(org.activiti.api.process.model.ProcessInstance) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) ServiceActivator(org.springframework.integration.annotation.ServiceActivator)

Aggregations

ServiceActivator (org.springframework.integration.annotation.ServiceActivator)15 Bean (org.springframework.context.annotation.Bean)7 FileInputStream (java.io.FileInputStream)4 File (java.io.File)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 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 ProcessInstance (org.activiti.api.process.model.ProcessInstance)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