Пример #1
0
 /**
  * Return a new sender for the message queue with the passed lookup name.
  *
  * @param string $lookupName The lookup name of the queue to return a sender for
  * @param string $sessionId  The session-ID to be passed to the queue session
  *
  * @return \AppserverIo\Messaging\QueueSender The sender instance
  */
 public function createSenderForQueue($lookupName, $sessionId = null)
 {
     // load the application name
     $application = $this->getApplication();
     $applicationName = $application->getName();
     $webappPath = $application->getWebappPath();
     // initialize the variable for the properties
     $properties = null;
     // load the configuration base directory
     if ($baseDirectory = $this->getManagerSettings()->getBaseDirectory()) {
         // look for naming context properties in the manager's base directory
         $propertiesFile = DirectoryKeys::realpath(sprintf('%s/%s/%s', $webappPath, $baseDirectory, QueueManagerSettingsInterface::CONFIGURATION_FILE));
         // load the properties from the configuration file
         if (file_exists($propertiesFile)) {
             $properties = Properties::create()->load($propertiesFile);
         }
     }
     // initialize and return the sender
     $queue = \AppserverIo\Messaging\MessageQueue::createQueue($lookupName);
     $connection = \AppserverIo\Messaging\QueueConnectionFactory::createQueueConnection($applicationName, $properties);
     $session = $connection->createQueueSession();
     return $session->createSender($queue);
 }
Пример #2
0
 /**
  * Return a new sender for the message queue with the passed lookup name.
  *
  * @param string $lookupName The lookup name of the queue to return a sender for
  * @param string $sessionId  The session-ID to be passed to the queue session
  *
  * @return \AppserverIo\Messaging\QueueSender The sender instance
  */
 public function createSenderForQueue($lookupName, $sessionId = null)
 {
     // load the application name
     $applicationName = $this->getApplication()->getName();
     // initialize and return the sender
     $queue = \AppserverIo\Messaging\MessageQueue::createQueue($lookupName);
     $connection = \AppserverIo\Messaging\QueueConnectionFactory::createQueueConnection($applicationName);
     $session = $connection->createQueueSession();
     return $session->createSender($queue);
 }