Excluded EntityAlreadyExists exceptions from requeuing (#883)
* excluded EntityAlreadyExists exceptions from requeuing Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * moved the catch clause closer to the thrown exception Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * reverted AmqpMessageHandlerServiceIntegrationTest package change Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * reduced scope of method variable Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com> * removed instantiation of exceptions Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>
This commit is contained in:
committed by
Dominic Schabel
parent
c68c5a6f5b
commit
973f1952c7
@@ -110,7 +110,7 @@ import com.google.common.collect.Sets;
|
||||
@Transactional(readOnly = true)
|
||||
@Validated
|
||||
public class JpaControllerManagement implements ControllerManagement {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ControllerManagement.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JpaControllerManagement.class);
|
||||
|
||||
private final BlockingDeque<TargetPoll> queue;
|
||||
|
||||
@@ -387,23 +387,15 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
}
|
||||
|
||||
private Target createTarget(final String controllerId, final URI address) {
|
||||
try {
|
||||
final Target result = targetRepository.save((JpaTarget) entityFactory.target().create()
|
||||
.controllerId(controllerId).description("Plug and Play target: " + controllerId).name(controllerId)
|
||||
.status(TargetUpdateStatus.REGISTERED).lastTargetQuery(System.currentTimeMillis())
|
||||
.address(Optional.ofNullable(address).map(URI::toString).orElse(null)).build());
|
||||
final Target result = targetRepository.save((JpaTarget) entityFactory.target().create()
|
||||
.controllerId(controllerId).description("Plug and Play target: " + controllerId).name(controllerId)
|
||||
.status(TargetUpdateStatus.REGISTERED).lastTargetQuery(System.currentTimeMillis())
|
||||
.address(Optional.ofNullable(address).map(URI::toString).orElse(null)).build());
|
||||
|
||||
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher()
|
||||
.publishEvent(new TargetPollEvent(result, eventPublisherHolder.getApplicationId())));
|
||||
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher()
|
||||
.publishEvent(new TargetPollEvent(result, eventPublisherHolder.getApplicationId())));
|
||||
|
||||
return result;
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
LOG.warn(
|
||||
"Caught an EntityAlreadyExistsException while creating non existing target "
|
||||
+ "[controllerId:{}, address:{}, tenant: {}]",
|
||||
controllerId, address, tenantAware.getCurrentTenant());
|
||||
throw e;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user