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);
}