package Ġbr . com . p oc Ċ Ċ import Ġbr . com . p oc . domain . Transaction . Transaction Status Ċ import Ġbr . com . p oc . domain . event . Transaction Response Ċ import Ġbr . com . p oc . repository . Transaction InMemory Repository Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġorg . springframework . amqp . rabbit . annotation . Rabbit Listener Ċ import Ġorg . springframework . stereotype . Component Ċ Ċ @ Component Ċ class ĠTransaction Consumer ( ĊĠĠĠ Ġval Ġtransaction Repository : ĠTransaction InMemory Repository Ċ ) Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġlog Ġ= ĠLoggerFactory . getLogger ( this :: class . java ) ĊĊĠĠĠ Ġ@ Rabbit Listener ( queues Ġ= Ġ[" response - queue "]) ĊĠĠĠ Ġfun Ġexecute ( response : ĠTransaction Response ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlog . info (" Processing Ġresponse = [$ response ]") ĊĠĠĠĠĠĠĠ Ġval Ġcorrelation Id Ġ= Ġresponse . metadata . correlation Id ĊĠĠĠĠĠĠĠ Ġif Ġ( transaction Repository . exists ( correlation Id )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtransaction Ġ= Ġtransaction Repository . findById ( correlation Id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠRuntimeException (" Transact in = [$ correlation Id ] Ġwas Ġnot Ġfound ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction . status Ġ= ĠTransaction Status . valueOf ( response . status . uppercase ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransaction Repository . save ( transaction ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlog . warn (" Discard ing Ġ${ Transaction Response :: class . java . simple Name } Ġcorrelation Id = [$ correlation Id ]") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }