http://wiki4.caucho.com/index.php?title=Resin_ActiveMQ_How_to&feed=atom&action=history
Resin ActiveMQ How to - Revision history
2024-03-28T21:25:58Z
Revision history for this page on the wiki
MediaWiki 1.18.0
http://wiki4.caucho.com/index.php?title=Resin_ActiveMQ_How_to&diff=1042&oldid=prev
Rick at 00:00, 7 February 2013
2013-02-07T00:00:00Z
<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 00:00, 7 February 2013</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>== Resin, ActiveMQ and <del class="diffchange diffchange-inline">JCA </del>==</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>== Resin, ActiveMQ and <ins class="diffchange diffchange-inline">CDI </ins>==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
</table>
Rick
http://wiki4.caucho.com/index.php?title=Resin_ActiveMQ_How_to&diff=1041&oldid=prev
Rick: Created page with " == Resin, ActiveMQ and JCA == ActiveMQ can be used from Resin using Resin's CDI support. Then, in your resin-web.xml (under WEB-INF of your webapp), you'll need to config..."
2013-02-07T00:00:00Z
<p>Created page with " == Resin, ActiveMQ and JCA == ActiveMQ can be used from Resin using Resin's CDI support. Then, in your resin-web.xml (under WEB-INF of your webapp), you'll need to config..."</p>
<p><b>New page</b></p><div><br />
== Resin, ActiveMQ and JCA ==<br />
<br />
<br />
ActiveMQ can be used from Resin using Resin's CDI support.<br />
<br />
<br />
Then, in your resin-web.xml (under WEB-INF of your webapp), you'll need to configure the ActiveMA as follows:<br />
<br />
<code><pre><br />
<?xml version="1.0" encoding="UTF-8" ?><br />
<web-app xmlns="http://caucho.com/ns/resin" xmlns:activemq="urn:java:org.apache.activemq"<br />
xmlns:queue="urn:java:org.apache.activemq.command"<br />
xmlns:ee="urn:java:ee"><br />
<br />
<activemq:ActiveMQConnectionFactory<br />
broker-url="vm://localhost"><br />
<ee:Named>activemq</ee:Named><br />
<ee:ApplicationScoped /><br />
</activemq:ActiveMQConnectionFactory><br />
<queue:ActiveMQQueue physical-name="queue.test"><br />
<ee:Named>test</ee:Named><br />
</queue:ActiveMQQueue><br />
</web-app><br />
</pre></code><br />
<br />
The Java code looks as follows:<br />
<br />
<code><pre><br />
package com.example;<br />
<br />
import java.io.IOException;<br />
<br />
import javax.inject.Inject;<br />
import javax.inject.Named;<br />
import javax.jms.JMSException;<br />
import javax.jms.Queue;<br />
import javax.jms.QueueConnection;<br />
import javax.jms.QueueConnectionFactory;<br />
import javax.jms.QueueSender;<br />
import javax.jms.QueueSession;<br />
import javax.servlet.ServletException;<br />
import javax.servlet.annotation.WebServlet;<br />
import javax.servlet.http.HttpServlet;<br />
import javax.servlet.http.HttpServletRequest;<br />
import javax.servlet.http.HttpServletResponse;<br />
<br />
/**<br />
* Servlet implementation class Sender<br />
*/<br />
@WebServlet("/Sender")<br />
public class Sender extends HttpServlet {<br />
<br />
@Inject @Named("activemq")<br />
QueueConnectionFactory _factory;<br />
@Inject @Named("test")<br />
Queue _queue;<br />
<br />
protected void doGet(HttpServletRequest request,<br />
HttpServletResponse response) throws ServletException, IOException {<br />
<br />
QueueConnection conn = null;<br />
QueueSession session = null;<br />
QueueSender sender = null;<br />
<br />
try {<br />
<br />
conn = _factory.createQueueConnection();<br />
session = conn.createQueueSession(false,<br />
QueueSession.AUTO_ACKNOWLEDGE);<br />
sender = session.createSender(_queue);<br />
sender.send(_queue, session.createTextMessage("test"));<br />
response.getWriter().println("SENT");<br />
<br />
} catch (JMSException e) {<br />
throw new ServletException(e);<br />
} finally {<br />
try {<br />
conn.close();<br />
session.close();<br />
sender.close();<br />
} catch (JMSException e) {<br />
throw new ServletException(e);<br />
}<br />
}<br />
}<br />
<br />
}<br />
<br />
</pre></code></div>
Rick