28 Mart 2017 Salı

EnvironmentPostProcessor Sınıfı

Şöyle yaparız.
public class DatabasePropertiesEnvPostProcessor implements
  EnvironmentPostProcessor {
  @Override
  public void postProcessEnvironment(ConfigurableEnvironment environment,
    SpringApplication application) {

    Properties props = new Properties();
    props.put("spring.datasource.url", "<my value>"); 
    environment.getPropertySources().addFirst(
      new PropertiesPropertySource("dbProps", props));
  }
}
spring.factories dosyasına şu satırı ekleriz.
org.springframework.context.ApplicationListener=com.DatabasePropertiesListener

18 Mart 2017 Cumartesi

SpringIntegration DirectChannel Sınıfı

channel
Şöyle yaparız.
<channel id="pollable">
    <queue/>
</channel>
bridge
Şöyle yaparız.
<bridge input-channel="pollable" output-channel="subscribable">
    <poller max-messages-per-poll="10" fixed-rate="5000" />
</bridge>
DirectChannel Sınıfı
Açıklaması şöyle
DirectChannel will be picked by default by Spring Integration to wire up the endpoints of your integration flow. This means that as long as your endpoints stay synchronous and you rely on default channels between them, the whole integration flow stay synchronous as well.
Şöyle yaparız.
@Bean
public IntegrationFlow syncFlow() {
  return IntegrationFlows
    .from(/* get a REST message from microservice */)
    // here the DirectChannel is used by default 
    .filter(/* validate (and filter out) incorrect messages */)
    // here the DirectChannel is used by default too
    .transform(/* map REST to SOAP */)
    // guess what would be here?
    .handle(/* send a message with SOAP client */)
    .get();
  }
ExecutorChannel Sınıfı
Şöyle yaparız.
@Bean
public IntegrationFlow syncFlow() {
  // ... the same as above ...
  .transform(/* map REST to SOAP */)
  .channel(c -> c.executor(Executors.newCachedThreadPool()))  // see (1)
  .handle(/* send a message with SOAP client */)
  .get();
}