Delomboking
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user