Delomboking

This commit is contained in:
Marcin Grzejszczak
2016-02-10 19:09:20 +01:00
parent 8f5f553376
commit ee8d7a54c7
68 changed files with 687 additions and 391 deletions

View File

@@ -16,14 +16,13 @@
package sample;
import lombok.SneakyThrows;
import java.util.Random;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Random;
/**
* @author Spencer Gibb
*/
@@ -35,9 +34,8 @@ public class SampleBackground {
@Autowired
private Random random;
@SneakyThrows
@Async
public void background() {
public void background() throws InterruptedException {
int millis = this.random.nextInt(1000);
Thread.sleep(millis);
this.tracer.addTag("background-sleep-millis", String.valueOf(millis));

View File

@@ -16,8 +16,7 @@
package sample;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.context.ApplicationListener;
@@ -30,10 +29,11 @@ import org.springframework.web.client.RestTemplate;
* @author Dave Syer
*
*/
@MessageEndpoint
@Slf4j
public class SampleService implements
@MessageEndpoint public class SampleService implements
ApplicationListener<EmbeddedServletContainerInitializedEvent> {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(SampleService.class);
@Autowired private RestTemplate restTemplate;
private int port;

View File

@@ -16,8 +16,7 @@
package sample;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
@@ -28,14 +27,16 @@ import org.springframework.messaging.Message;
*
*/
@MessageEndpoint
@Slf4j
public class SampleTransformer {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(SampleTransformer.class);
@Autowired
SampleBackground background;
@ServiceActivator(inputChannel="xform")
public String log(Message<?> message) {
public String log(Message<?> message) throws InterruptedException {
log.info("Received: " + message);
this.background.background();
return message.getPayload().toString().toUpperCase();