code: @Override
      public void run()
      {
          logger.debug("*******************************************************************************");
          logger.info("***********                    begin dial local to AGI                  ****************");
          logger.debug("***********                                                      ****************");
          logger.debug("*******************************************************************************");
          final AsteriskSettings settings = PBXFactory.getActiveProfile();
  
          AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX();
  
          final OriginateAction originate = new OriginateAction();
          originate.setEndPoint(from);
          originate.setContext(settings.getManagementContext());
          originate.setExten(pbx.getExtensionAgi());
          originate.setPriority(1);
          originate.setCallerId(fromCallerID);
          originate.setTimeout(30000);
  
          Map<String, String> myVars = new HashMap<>();
  
          if (channelVarsToSet != null)
          {
              myVars.putAll(channelVarsToSet);
          }
  
          originate.setVariables(myVars);
  
          ActivityArrivalListener listener = new ActivityArrivalListener()
          {
  
              @Override
              public void channelArrived(Channel channel)
              {
                  channels.add(channel);
                  if (isSuccess())
                  {
                      latch.countDown();
                  }
              }
          };
          try (AutoCloseable closeable = ActivityAgi.addArrivalListener(originate, listener);)
          {
  
              ManagerResponse response = pbx.sendAction(originate, 5000);
              if (response.getResponse().compareToIgnoreCase("Success") != 0)
              {
                  callback.progress(this, ActivityStatusEnum.FAILURE, ActivityStatusEnum.FAILURE.getDefaultMessage());
              }
              else
              {
                  if (latch.await(5, TimeUnit.SECONDS))
                  {
                      callback.progress(this, ActivityStatusEnum.SUCCESS, ActivityStatusEnum.SUCCESS.getDefaultMessage());
                  }
                  else
                  {
                      callback.progress(this, ActivityStatusEnum.FAILURE, ActivityStatusEnum.FAILURE.getDefaultMessage());
                  }
              }
          }
          catch (Exception e)
          {
              logger.error(e, e);
              callback.progress(this, ActivityStatusEnum.FAILURE, ActivityStatusEnum.FAILURE.getDefaultMessage());
  
          }
  
      }
docs: Logger logger = LogManager.getLogger();