Base Task Sink Case with Tests works
In process of migrating batch-events to streambridge BatchEvents Migrated Integration tests for TaskSink now work Batch Event Integration Tests updated Added tests to batch events Event integration tests added Updated with the last bit of tests baseline polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,14 +18,15 @@ package io.spring;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.messaging.Processor;
|
||||
import org.springframework.cloud.task.launcher.TaskLaunchRequest;
|
||||
import org.springframework.integration.annotation.Transformer;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -34,41 +35,43 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
@EnableBinding(Processor.class)
|
||||
@EnableConfigurationProperties(TaskProcessorProperties.class)
|
||||
@Configuration
|
||||
public class TaskProcessor {
|
||||
|
||||
@Autowired
|
||||
private TaskProcessorProperties processorProperties;
|
||||
|
||||
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
|
||||
public Object setupRequest(String message) {
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
if (StringUtils.hasText(this.processorProperties.getDataSourceUrl())) {
|
||||
properties
|
||||
.put("spring_datasource_url", this.processorProperties
|
||||
.getDataSourceUrl());
|
||||
}
|
||||
if (StringUtils
|
||||
.hasText(this.processorProperties.getDataSourceDriverClassName())) {
|
||||
properties.put("spring_datasource_driverClassName", this.processorProperties
|
||||
.getDataSourceDriverClassName());
|
||||
}
|
||||
if (StringUtils.hasText(this.processorProperties.getDataSourceUserName())) {
|
||||
properties.put("spring_datasource_username", this.processorProperties
|
||||
.getDataSourceUserName());
|
||||
}
|
||||
if (StringUtils.hasText(this.processorProperties.getDataSourcePassword())) {
|
||||
properties.put("spring_datasource_password", this.processorProperties
|
||||
.getDataSourcePassword());
|
||||
}
|
||||
properties.put("payload", message);
|
||||
@Bean
|
||||
public Function<Message<String>, Message<TaskLaunchRequest>> processRequest() {
|
||||
return (messagePayload) -> {
|
||||
String message = messagePayload.getPayload();
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
if (StringUtils.hasText(this.processorProperties.getDataSourceUrl())) {
|
||||
properties
|
||||
.put("spring_datasource_url", this.processorProperties
|
||||
.getDataSourceUrl());
|
||||
}
|
||||
if (StringUtils
|
||||
.hasText(this.processorProperties.getDataSourceDriverClassName())) {
|
||||
properties.put("spring_datasource_driverClassName", this.processorProperties
|
||||
.getDataSourceDriverClassName());
|
||||
}
|
||||
if (StringUtils.hasText(this.processorProperties.getDataSourceUserName())) {
|
||||
properties.put("spring_datasource_username", this.processorProperties
|
||||
.getDataSourceUserName());
|
||||
}
|
||||
if (StringUtils.hasText(this.processorProperties.getDataSourcePassword())) {
|
||||
properties.put("spring_datasource_password", this.processorProperties
|
||||
.getDataSourcePassword());
|
||||
}
|
||||
properties.put("payload", message);
|
||||
|
||||
TaskLaunchRequest request = new TaskLaunchRequest(
|
||||
this.processorProperties.getUri(), null, properties, null,
|
||||
this.processorProperties.getApplicationName());
|
||||
TaskLaunchRequest request = new TaskLaunchRequest(
|
||||
this.processorProperties.getUri(), null, properties, null,
|
||||
this.processorProperties.getApplicationName());
|
||||
|
||||
return new GenericMessage<>(request);
|
||||
return MessageBuilder.withPayload(request).build();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
maven.remoteRepositories.springRepo.url=https://repo.spring.io/libs-snapshot
|
||||
spring.cloud.stream.function.bindings.processRequest-in-0=input
|
||||
spring.cloud.stream.function.bindings.processRequest-out-0=output
|
||||
Reference in New Issue
Block a user