Hi,
testing my first JMS-experiences in Geronimo 2.1.1, I thought why not test
it with the openjpa embedded container. We have a lot of stateless session
beans which work wonderful in the embedded container openejb 3.0, but for
the injection of the JMS-ConnectionFactory in my test-cases I need a hint.
The Testclass should write a Textmessage in a JMS-Queue:
public class MyTest {
@Resource
private ConnectionFactory factory;
@Resource
private Queue receivingQueue;
...
@Test
public void sendMessage() throws Exception{
Connection connection = null;
MessageProducer messageProducer = null;
Session sess = null;
connection = factory.createConnection();
sess = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
TextMessage msg = sess.createTextMessage("Hallo World!!"
);
messageProducer = sess.createProducer(receivingQueue);
messageProducer.send(msg);
System.out.println("(client) Test Request Send");
}
I defined the Queue and the ConnectionFactory using the Geronimo-Console
for my Geronimo 2.1.1. If I am right, I have to define this as well once
more for the openejb embedded container:
openejb.conf:
...
<Resource id="Default JMS Resource Adapter"
type="ActiveMQResourceAdapter">
# Broker configuration
BrokerXmlConfig broker:(tcp://localhost:61617)?useJmx=false
UserName user
Password pwd
# Broker address
ServerUrl vm://localhost?async=true
</Resource>
<Resource id="factory" type="javax.jms.ConnectionFactory">
ResourceAdapter Default JMS Resource Adapter
TransactionSupport xa
PoolMaxSize 10
PoolMinSize 0
ConnectionMaxWaitMilliseconds 5000
ConnectionMaxIdleMinutes 15
destination MyQueueName
</Resource>
<Resource id="receivingQueue" type="javax.jms.Queue">
destination MyConnectionFactoryName
</Resource>
....
My Problem is that factory and receivingQueue are always null, there is no
Resource-Injection. I tried also:
@Resource(name="MyConnectionFactoryName")
private ConnectionFactory factory;
Thank you very much
Josef
BGS Beratungsgesellschaft
Software Systemplanung AG
Niederlassung Rhein/Main
Robert-Koch-Straße 41
55129 Mainz
Fon: +49 (0) 6131 / 914-0
Fax: +49 (0) 6131 / 914-400
www.bgs-ag.de
Geschäftssitz Mainz
Registergericht
Amtsgericht Mainz
HRB 62 50
Aufsichtsratsvorsitzender
Klaus Hellwig
Vorstand
Hanspeter Gau
Hermann Kiefer
Nils Manegold