private void process(ObjectMessage msg) throws JMSException {
   String remoteAET = msg.getStringProperty("RemoteAET");
   String localAET = msg.getStringProperty("LocalAET");
   String iuid = msg.getStringProperty("SOPInstancesUID");
   boolean ncreate = msg.getBooleanProperty("N_CREATE_RQ");
   int retries = msg.getIntProperty("Retries");
   Attributes rqAttrs = (Attributes) msg.getObject();
   ArchiveApplicationEntity localAE =
       (ArchiveApplicationEntity) device.getApplicationEntity(localAET);
   if (localAE == null) {
     LOG.warn("Failed to forward MPPS to {} - no such local AE: {}", remoteAET, localAET);
     return;
   }
   TransferCapability tc =
       localAE.getTransferCapabilityFor(
           UID.ModalityPerformedProcedureStepSOPClass, TransferCapability.Role.SCU);
   if (tc == null) {
     LOG.warn(
         "Failed to forward MPPS to {} - local AE: {} does not support Modality Performed Procedure Step SOP Class in SCU Role",
         remoteAET,
         localAET);
     return;
   }
   AAssociateRQ aarq = new AAssociateRQ();
   aarq.addPresentationContext(
       new PresentationContext(
           1, UID.ModalityPerformedProcedureStepSOPClass, tc.getTransferSyntaxes()));
   try {
     ApplicationEntity remoteAE = aeCache.findApplicationEntity(remoteAET);
     Association as = localAE.connect(remoteAE, aarq);
     DimseRSP rsp =
         ncreate
             ? as.ncreate(UID.ModalityPerformedProcedureStepSOPClass, iuid, rqAttrs, null)
             : as.nset(UID.ModalityPerformedProcedureStepSOPClass, iuid, rqAttrs, null);
     rsp.next();
     try {
       as.release();
     } catch (IOException e) {
       LOG.info("{}: Failed to release association to {}", as, remoteAET);
     }
     if (!ncreate && rsp.getCommand().getInt(Tag.Status, -1) == Status.NoSuchObjectInstance) {
       throw new DicomServiceException(Status.NoSuchObjectInstance);
     }
   } catch (Exception e) {
     if (retries < localAE.getForwardMPPSMaxRetries()) {
       int delay = localAE.getForwardMPPSRetryInterval();
       LOG.info("Failed to forward MPPS to " + remoteAET + " - retry in " + delay + "s", e);
       scheduleForwardMPPS(localAET, remoteAET, iuid, rqAttrs, ncreate, retries + 1, delay);
     } else {
       LOG.warn("Failed to forward MPPS to " + remoteAET, e);
     }
   }
 }
 private void process(ObjectMessage msg) throws JMSException {
   String remoteAET = msg.getStringProperty("RemoteAET");
   String localAET = msg.getStringProperty("LocalAET");
   int retries = msg.getIntProperty("Retries");
   Attributes ian = (Attributes) msg.getObject();
   ArchiveApplicationEntity localAE =
       (ArchiveApplicationEntity) device.getApplicationEntity(localAET);
   if (localAE == null) {
     LOG.warn("Failed to send IAN to {} - no such local AE: {}", remoteAET, localAET);
     return;
   }
   TransferCapability tc =
       localAE.getTransferCapabilityFor(
           UID.InstanceAvailabilityNotificationSOPClass, TransferCapability.Role.SCU);
   if (tc == null) {
     LOG.warn(
         "Failed to send IAN to {} - local AE: {} does not support Instance Availability Notification SOP Class in SCU Role",
         remoteAET,
         localAET);
     return;
   }
   AAssociateRQ aarq = new AAssociateRQ();
   aarq.addPresentationContext(
       new PresentationContext(
           1, UID.InstanceAvailabilityNotificationSOPClass, tc.getTransferSyntaxes()));
   try {
     ApplicationEntity remoteAE = aeCache.findApplicationEntity(remoteAET);
     Association as = localAE.connect(remoteAE, aarq);
     DimseRSP rsp =
         as.ncreate(UID.InstanceAvailabilityNotificationSOPClass, UIDUtils.createUID(), ian, null);
     rsp.next();
     try {
       as.release();
     } catch (IOException e) {
       LOG.info("{}: Failed to release association to {}", as, remoteAET);
     }
   } catch (Exception e) {
     if (retries < localAE.getIANMaxRetries()) {
       int delay = localAE.getIANRetryInterval();
       LOG.info("Failed to send IAN to " + remoteAET + " - retry in " + delay + "s", e);
       scheduleIAN(localAET, remoteAET, ian, retries + 1, delay);
     } else {
       LOG.warn("Failed to send IAN to " + remoteAET, e);
     }
   }
 }