Created
September 26, 2012 18:48
-
-
Save solo-seven/3789799 to your computer and use it in GitHub Desktop.
Here are the basic configuration components necessary for adding support for the 0.17 QPID JCA adapter to Glassfish. There have been basic tests done to connect with Red Hat Messaging 2.1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<applications> | |
<!-- Snip --> | |
<application location="${com.sun.aas.instanceRootURI}/applications/qpid-ra-0.17.rar" name="qpid-ra-0.17" object-type="user"> | |
<property name="preserveAppScopedResources" value="false"></property> | |
<property name="defaultAppName" value="qpid-ra-0.17"></property> | |
<module name="qpid-ra-0.17"> | |
<engine sniffer="connector"></engine> | |
</module> | |
</application> | |
<!-- Snip --> | |
</applications> | |
<resources> | |
<!-- Snip --> | |
<connector-connection-pool description="QpidJMSXAPool" name="QpidJMSXAPool" resource-adapter-name="qpid-ra-0.17" connection-definition-name="org.apache.qpid.ra.QpidRAConnectionFactory" ping="tru | |
e" transaction-support="XATransaction"> | |
<property name="connectionURL" value="amqp://guest:guest@client/test?brokerlist='tcp://localhost:5672'"></property> | |
<property name="SessionDefaultType" value="javax.jms.Queue"></property> | |
</connector-connection-pool> | |
<connector-resource pool-name="QpidJMSXAPool" jndi-name="QpidJMSXAPool"></connector-resource> | |
<resource-adapter-config thread-pool-ids="thread-pool-1" resource-adapter-name="qpid-ra-0.17"> | |
<property name="TransactionManagerLocatorMethod" value="getTm"></property> | |
<property name="TransactionManagerLocatorClass" value="org.apache.qpid.ra.tm.GlassfishTransactionManagerLocator"></property> | |
</resource-adapter-config> | |
<admin-object-resource res-adapter="qpid-ra-0.17" res-type="org.apache.qpid.ra.admin.QpidQueue" jndi-name="SampleQueue" class-name="org.apache.qpid.ra.admin.QpidQueueImpl"> | |
<property name="DestinationAddress" value="sampleQueue"></property> | |
</admin-object-resource> | |
<!-- Snip --> | |
</resources> | |
<servers> | |
<server name="server" config-ref="server-config"> | |
<!-- Snip --> | |
<application-ref ref="qpid-ra-0.17" virtual-servers="server"></application-ref> | |
<resource-ref ref="SampleQueue"></resource-ref> | |
<!-- Snip --> | |
</server> | |
</servers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.redhat.jboss.web; | |
import javax.ws.rs.ApplicationPath; | |
import javax.ws.rs.core.Application; | |
/** | |
* @author bashburn | |
* | |
*/ | |
@ApplicationPath("/rest") | |
public class JaxRsActivator extends Application { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from qpid.messaging import * | |
connection = Connection("localhost:5672") | |
try: | |
connection.open() | |
session = connection.session() | |
receiver = session.receiver("mytestqueue") | |
message = receiver.fetch(timeout=1) | |
print message.content | |
session.acknowledge() | |
except MessagingError,m: | |
print m | |
connection.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root ~]# qpid-config -b queues | |
Queue 'mytestqueue' | |
bind [mytestqueue] => '' | |
bind [test.subject] => amq.topic | |
Queue 'qmfc-v2-hb-rhgfmsg1.1733.1' | |
bind [qmfc-v2-hb-rhgfmsg1.1733.1] => '' | |
bind [agent.ind.heartbeat.#] => qmf.default.topic | |
Queue 'qmfc-v2-rhgfmsg1.1733.1' | |
bind [qmfc-v2-rhgfmsg1.1733.1] => '' | |
bind [qmfc-v2-rhgfmsg1.1733.1] => qmf.default.direct | |
Queue 'qmfc-v2-ui-rhgfmsg1.1733.1' | |
bind [qmfc-v2-ui-rhgfmsg1.1733.1] => '' | |
Queue 'reply-rhgfmsg1.1733.1' | |
bind [reply-rhgfmsg1.1733.1] => '' | |
bind [reply-rhgfmsg1.1733.1] => amq.direct | |
Queue 'sampleQueue' | |
bind [sampleQueue] => '' | |
bind [sampleQueue] => amq.direct | |
Queue 'topic-rhgfmsg1.1733.1' | |
bind [topic-rhgfmsg1.1733.1] => '' | |
bind [console.event.*.*.org.apache.qpid.broker.agent] => qpid.management | |
bind [console.obj.*.*.org.apache.qpid.broker.agent] => qpid.management | |
bind [schema.#] => qpid.management |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from qpid.messaging import * | |
connection = Connection("localhost:5672") | |
try: | |
connection.open() | |
session = connection.session() | |
sender = session.sender("amq.direct") | |
message = Message("Hello World!") | |
message.subject = 'sampleQueue' | |
sender.send(message) | |
session.acknowledge() | |
except MessagingError,m: | |
print m | |
connection.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.jboss.demo.msg; | |
import javax.ejb.ActivationConfigProperty; | |
import javax.ejb.MessageDriven; | |
import javax.jms.JMSException; | |
import javax.jms.Message; | |
import javax.jms.MessageListener; | |
import javax.jms.TextMessage; | |
/** | |
* @author bashburn | |
* | |
*/ | |
@MessageDriven( | |
mappedName = "SampleQueue", | |
activationConfig = { | |
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), | |
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), | |
@ActivationConfigProperty(propertyName = "connectionURL", propertyValue = "amqp://guest:guest@client/test?brokerlist='tcp://localhost:5672'"), | |
@ActivationConfigProperty(propertyName = "destination", propertyValue = "SampleQueue") | |
} | |
) | |
public class SimpleMessageBean implements MessageListener { | |
/* (non-Javadoc) | |
* @see javax.jms.MessageListener#onMessage(javax.jms.Message) | |
*/ | |
public void onMessage(Message message) { | |
System.out.println("Message:" + message.toString()); | |
if(message instanceof TextMessage) { | |
try { | |
System.out.println("Message:" + ((TextMessage)message).getText()); | |
} catch(JMSException e) { | |
System.out.println("Error printing message:" + e.getMessage()); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.redhat.jboss.web; | |
import javax.jms.Connection; | |
import javax.jms.ConnectionFactory; | |
import javax.jms.Destination; | |
import javax.jms.Message; | |
import javax.jms.MessageProducer; | |
import javax.jms.Session; | |
import javax.naming.Context; | |
import javax.naming.InitialContext; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
/** | |
* @author bashburn | |
* | |
*/ | |
@Path("/simple") | |
public class SimpleRest { | |
@GET | |
public String execute() { | |
try { | |
Context ctx = new InitialContext(); | |
ConnectionFactory cf = (ConnectionFactory)ctx.lookup("QpidJMSXAPool"); | |
Destination dest = (Destination)ctx.lookup("SampleTopic"); | |
Connection conn = cf.createConnection(); | |
conn.start(); | |
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); | |
MessageProducer prod = sess.createProducer(dest); | |
Message message = sess.createTextMessage("TEST MESSAGE"); | |
message.setStringProperty("qpid.subject", "test.subject"); | |
prod.send(message); | |
conn.close(); | |
} catch(Exception e) { | |
return "FAILURE" + e.getMessage(); | |
} | |
return "SUCCESS"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment