[25.09.20] Added GatewayDLQ use

This commit is contained in:
Andy Sotheran 2020-09-25 13:57:34 +01:00
parent cd82fec43a
commit 9434872193
2 changed files with 20 additions and 2 deletions

View File

@ -33,6 +33,7 @@ public class PriceConsumer {
private final PriceService priceService; private final PriceService priceService;
private final DlqService dlqService; private final DlqService dlqService;
private final String dlqName; private final String dlqName;
private final String dlqGateway;
private CountDownLatch latch = new CountDownLatch(1); private CountDownLatch latch = new CountDownLatch(1);
@ -41,12 +42,14 @@ public class PriceConsumer {
ObjectMapper objectMapper, ObjectMapper objectMapper,
PriceService priceService, PriceService priceService,
DlqService dlqService, DlqService dlqService,
@Value("${destinations.pricing.priceDlq}") String dlqName @Value("${destinations.pricing.priceDlq}") String dlqName,
@Value("${destinations.gateway.gatewayDlq}") String dlqGateway
) { ) {
this.objectMapper = objectMapper; this.objectMapper = objectMapper;
this.priceService = priceService; this.priceService = priceService;
this.dlqService = dlqService; this.dlqService = dlqService;
this.dlqName = dlqName; this.dlqName = dlqName;
this.dlqGateway = dlqGateway;
} }
@JmsListener(destination = "${destinations.pricing.priceSave}") @JmsListener(destination = "${destinations.pricing.priceSave}")
@ -100,7 +103,20 @@ public class PriceConsumer {
}); });
latch.countDown(); latch.countDown();
} catch (JMSException jmsException) { } catch (JMSException jmsException) {
logger.error("An Exception has occurred with a JMS action [%s]", jmsException); String dlqReason = format("An Exception [%s] has occurred with a JMS action [%s] on [%s]", CONSUME_PRICE_EVENT, jmsException,
correlationId);
DlqInfo dlqInfo = new DlqInfo(
message.getJMSMessageID(),
dlqGateway,
dlqReason,
"0",
correlationId
);
dlqService.sendToDlq(message, CONSUME_PRICE_EVENT.getMessage(), dlqInfo, jmsException, textMessage -> {
textMessage.setStringProperty(MESSAGE_SAVE_SYNC_ID.getMessage(), syncId);
return textMessage;
});
latch.countDown(); latch.countDown();
} catch (Exception e) { } catch (Exception e) {
String dlqReason = format("Couldn't sync incoming %s for price event [%s]", CONSUME_PRICE_EVENT, correlationId); String dlqReason = format("Couldn't sync incoming %s for price event [%s]", CONSUME_PRICE_EVENT, correlationId);

View File

@ -30,6 +30,8 @@ destinations:
pricing: pricing:
priceSave: PricingSave priceSave: PricingSave
priceDlq: PricingSave.dlq priceDlq: PricingSave.dlq
gateway:
gatewayDlq: DBGateway.dlq
server: server:
port: 9090 port: 9090