7
7
import org .apache .logging .log4j .LogManager ;
8
8
import org .apache .logging .log4j .Logger ;
9
9
10
- import com .lacheff .commonutil .rabbitmq .RabbitGate ;
11
10
import com .lacheff .commonutil .rabbitmq .RabbitMessageHander ;
12
11
import com .lacheff .commonutil .rabbitmq .request .NlpProcessingRequest ;
13
12
import com .lacheff .commonutil .rabbitmq .request .NlpSummarizationRequest ;
17
16
import com .lacheff .commonutil .rabbitmq .support .RoutingKey ;
18
17
19
18
public class NlpProcessingRequestHandler implements RabbitMessageHander {
20
- private static Logger LOG = LogManager .getLogger (NlpProcessingRequestHandler .class );
21
-
22
-
23
-
24
- private RabbitGate rabbitGate = RabbitGateManager .getInstance ().getRabbitGate ();
19
+ private static Logger LOG = LogManager .getRootLogger ();
25
20
26
21
@ Override
27
22
public void handle (Object object ) {
28
- LOG .info ("Seeing this in the log means that message was send and received" );
29
-
23
+
30
24
if (object instanceof NlpProcessingRequest ) {
31
25
handleNlpProcessingRequest ((NlpProcessingRequest ) object );
32
26
} else if (object instanceof NlpSummarizationRequest ){
@@ -38,24 +32,32 @@ public void handle(Object object) {
38
32
}
39
33
40
34
private void handleNlpProcessingRequest (NlpProcessingRequest nlpProcessingRequest ) {
41
- LOG .info ("Got processing request: {}" , nlpProcessingRequest . getReviewUUID () );
35
+ LOG .info ("[x] Got processing request: {}" , nlpProcessingRequest );
42
36
try {
43
37
44
38
NlpProcessingResponse nlpProcessingResponse = new NlpProcessingResponse ();
45
- nlpProcessingResponse .setReviewUUID (new Date () + "" );
46
- LOG .debug ("Shipping response after NLP processing: {}" , nlpProcessingResponse );
47
- rabbitGate .send (nlpProcessingResponse );
39
+ nlpProcessingResponse .setReviewUUID (nlpProcessingRequest .getReviewUUID ());
40
+
41
+ LOG .info ("Shipping response after NLP processing: {}" , nlpProcessingResponse );
42
+ RabbitGateManager .getInstance ().getRabbitGate ().send (nlpProcessingResponse );
48
43
49
44
} catch (Exception ex ) {
50
45
LOG .error ("Exception at handleNlpProcessingRequest:" , ex );
51
46
}
52
47
}
53
48
54
49
private void handleNlpSummarizationRequest (NlpSummarizationRequest nlpSummarizationRequest ){
55
- LOG .debug ("Sending response after NLP Summarization Request" );
56
- NlpSummarizationResponse nlpSummarizationResponse = new NlpSummarizationResponse ();
57
- nlpSummarizationResponse .setRequestUUID (new Date () + "" );
58
- rabbitGate .send (nlpSummarizationResponse );
50
+ LOG .info ("[x] Got nlpSummarization request: {}" , nlpSummarizationRequest );
51
+ try {
52
+ NlpSummarizationResponse nlpSummarizationResponse = new NlpSummarizationResponse ();
53
+ nlpSummarizationResponse .setRequestUUID (new Date () + "" );
54
+
55
+ LOG .info ("Shipping response after NLP Summarization: {}" , nlpSummarizationResponse );
56
+ RabbitGateManager .getInstance ().getRabbitGate ().send (nlpSummarizationResponse );
57
+
58
+ } catch (Exception ex ) {
59
+ LOG .error ("Exception at handleSummarizationRequest:" , ex );
60
+ }
59
61
}
60
62
61
63
@ Override
0 commit comments