Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Message-Queue Client #299

Closed
wagnert opened this issue Dec 6, 2014 · 1 comment
Closed

Refactor Message-Queue Client #299

wagnert opened this issue Dec 6, 2014 · 1 comment
Assignees

Comments

@wagnert
Copy link
Member

wagnert commented Dec 6, 2014

The Message-Queue Client actually needs a bit complicated initialisation process:

// load the application name
$applicationName = $this->getApplication()->getName();

// initialize the connection and the session
$queue = MessageQueue::createQueue('pms/importChunk');
$connection = QueueConnectionFactory::createQueueConnection($applicationName);
$session = $connection->createQueueSession();
$sender = $session->createSender($queue);

UAC:

  • Using the Message-Queue Client MUST be similar to using the Persistence Container Client (wrapped by the InitialContext)
  • It MUST be possible that the initialised Client can bin injected like a Bean
@wagnert wagnert added this to the Release 1.0.0.0 "Iron Horse" milestone Dec 6, 2014
@wagnert wagnert self-assigned this Dec 11, 2014
@wagnert
Copy link
Member Author

wagnert commented Dec 15, 2014

Queue-Sender instances can not be injected like Managers

class MyServlet extends HttpServlet

    /**
     * The queue session to send a message with.
     *
     * @var \AppserverIo\MessageQueueClient\QueueSession
     * @Resource(name="pms/createASingleActionTimer")
     */
    protected $queueSender;

    /**
     * Handles a HTTP POST request.
     *
     * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequest  $servletRequest  The request instance
     * @param \AppserverIo\Psr\Servlet\Http\HttpServletResponse $servletResponse The response instance
     *
     * @return void
     * @throws \AppserverIo\Psr\Servlet\ServletException Is thrown if the request method is not implemented
     * @see \AppserverIo\Psr\Servlet\Http\HttpServlet::doGet()
     */
    public function doPost(HttpServletRequest $servletRequest, HttpServletResponse $servletResponse)
    {
        $this->queueSender->send(new IntegerMessage($this->duration));
    }
}

@wagnert wagnert closed this as completed Dec 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant