geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: JMS config and use under geronimo
Date Fri, 08 Aug 2008 16:15:44 GMT
To use jms you need two things in jndi: a connection factory and a  
destination (queue or topic).
On Aug 8, 2008, at 3:39 AM, zm wrote:

>
> I have a bit difficulty in understanding:
>
> 	<resource-ref>
> 		<description></description>
> 		<res-ref-name>jms/mycon</res-ref-name>
> 		<res-type>javax.jms.QueueConnectionFactory</res-type>
> 		<res-auth>Container</res-auth>
> 		<res-sharing-scope>Shareable</res-sharing-scope>
> 	</resource-ref>

the resource-ref is for the connection factory
>
>        <message-destination-ref>
>
> <message-destination-ref-name>jms/myqueue</message-destination-ref- 
> name>
>
> <message-destination-type>javax.jms.Queue</message-destination-type>
>
> <message-destination-usage>Consumes</message-destination-usage>
>                <message-destination-link>MyQueue</message- 
> destination-link>
>        </message-destination-ref>

the message-destination stuff is all for the destination (queue or  
topic).  You can also use a resource-env-ref.  The message-destination  
stuff is supposed to make it easier to hook up all uses of a  
particular destination in different modules in an ear, so you only  
have to hook it up to an actual particular destination once rather  
than in each module that uses it.  I'm not convinced at all that the  
message-destination actually simplifies things.
>
>
> Now the "resource-ref" defines a jndi resource on the J2EE platform.  
> But
> what about the "message-destination-ref"?
>
> When should I use "Consumes"/"Produces"? Should I create 2 entries,  
> one for
> when I post, and another when a retrieve a message? Is that it? (noob
> question really lol)

I think we ignore the -usage element and let you do whatever you want  
with the destination, we just make sure its there in jndi for you.
>
>
> What about the "message-destination-link" what value should it have?  
> Must it
> match some value around? Because I don't use it for message  
> posting ... for
> that I use "java:comp/env/jms/myqueue" as defined in
> "message-destination-ref-name" (this is the physical name right?) ?

I have a lot of trouble remembering how this is supposed to work and  
may well be wrong here.... I think you are supposed to have a <message- 
destination> element somewhere in your spec dds that matches the  
<message-destination-link>.  In your geronimo plan you'd then map the  
<message-destination> to a admin object deployed in some accessible  
activemq connector deployment (accessible means in the ear or a  
dependency of the ear).  If the message-destination name matches an  
admin object name then no entry in the geronimo plan is needed.

hope I'm reasonably close :-)
david jencks

>
>
>
> Thanks
>
>
>
>
>
> zm wrote:
>>
>> Hi,
>>
>> I'm looking forward to put a simple web application to work with JMS
>> messaging, but I can't seem to do it.
>>
>> I have not much experience doing it, so I'm getting a bit frustrated.
>>
>> First of all, my Java code that sends a message:
>>
>>
>> 		String message = "Text Message to Send!";
>> 		Connection connection = null;
>> 		Session session = null;
>>
>> 		try {
>> 			Context ctx = new InitialContext();
>> 			ConnectionFactory connectionFactory = (ConnectionFactory)  
>> ctx.lookup(
>> "java:comp/env/jms/mycon" );
>> 			Queue myQueue = (Queue) ctx.lookup( "java:comp/env/jms/myqueue" );
>>
>> 			connection = connectionFactory.createConnection();
>>
>> 			session = connection.createSession(false,  
>> Session.AUTO_ACKNOWLEDGE);
>>
>> 			MessageProducer producer = session.createProducer(myQueue);
>>
>> 			Message jmsMessage = session.createTextMessage( message );
>>
>> 			producer.send( jmsMessage );
>>
>> 		} catch(Throwable t) {
>> 			throw new Exception("Error found!", t);
>> 		} finally {
>> 			try {
>> 				if(session!=null) session.commit();
>> 			} catch(Throwable t) {
>> 			}
>> 			try {
>> 				if(connection!=null) connection.close();
>> 			} catch(Throwable t) {
>> 			}
>> 		}
>>
>>
>> In the web.xml:
>>
>> 	<resource-ref>
>> 		<description></description>
>> 		<res-ref-name>jms/mycon</res-ref-name>
>> 		<res-type>javax.jms.QueueConnectionFactory</res-type>
>> 		<res-auth>Container</res-auth>
>> 		<res-sharing-scope>Shareable</res-sharing-scope>
>> 	</resource-ref>
>> 	<message-destination-ref>
>> 		<message-destination-ref-name>jms/myqueue</message-destination- 
>> ref-name>
>> 		<message-destination-type>javax.jms.Queue</message-destination- 
>> type>
>> 		<message-destination-usage>Consumes</message-destination-usage>
>> 		<message-destination-link>MyQueue</message-destination-link>
>> 	</message-destination-ref>
>>
>>
>> Now to configure the Geronimo, I created selecting "for ActiveMQ"  
>> option
>> under the "JMS Resources", entered data that gave me the following  
>> deploy
>> plan:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2 
>> ">
>>    <dep:environment
>> xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2">
>>        <dep:moduleId>
>>            <dep:groupId>console.jms</dep:groupId>
>>            <dep:artifactId>mytest</dep:artifactId>
>>            <dep:version>1.0</dep:version>
>>            <dep:type>rar</dep:type>
>>        </dep:moduleId>
>>        <dep:dependencies>
>>            <dep:dependency>
>>                <dep:groupId>org.apache.geronimo.configs</dep:groupId>
>>                <dep:artifactId>activemq-broker</dep:artifactId>
>>                <dep:type>car</dep:type>
>>            </dep:dependency>
>>        </dep:dependencies>
>>    </dep:environment>
>>    <resourceadapter>
>>        <resourceadapter-instance>
>>            <resourceadapter-name>mytest</resourceadapter-name>
>>            <nam:workmanager
>> xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2">
>>                <nam:gbean-link>DefaultWorkManager</nam:gbean-link>
>>            </nam:workmanager>
>>        </resourceadapter-instance>
>>        <outbound-resourceadapter>
>>            <connection-definition>
>>
>> <connectionfactory-interface>javax.jms.QueueConnectionFactory</ 
>> connectionfactory-interface>
>>                <connectiondefinition-instance>
>>                    <name>jms/mycon</name>
>>                    <connectionmanager>
>>                        <xa-transaction>
>>                            <transaction-caching/>
>>                        </xa-transaction>
>>                        <single-pool>
>>                            <match-one/>
>>                        </single-pool>
>>                    </connectionmanager>
>>                </connectiondefinition-instance>
>>            </connection-definition>
>>        </outbound-resourceadapter>
>>    </resourceadapter>
>>    <adminobject>
>>        <adminobject-interface>javax.jms.Queue</adminobject-interface>
>>
>> <adminobject-class>org.apache.activemq.command.ActiveMQQueue</ 
>> adminobject-class>
>>        <adminobject-instance>
>>
>> <message-destination-name>jms/myqueue</message-destination-name>
>>            <config-property-setting
>> name="PhysicalName">jms/myqueue</config-property-setting>
>>        </adminobject-instance>
>>    </adminobject>
>>    <adminobject>
>>        <adminobject-interface>javax.jms.Topic</adminobject-interface>
>>
>> <adminobject-class>org.apache.activemq.command.ActiveMQTopic</ 
>> adminobject-class>
>>    </adminobject>
>> </connector>
>>
>>
>> In the "JMS Resources" list, I now have:
>>
>> mytest (console.jms/mytest/1.0/rar)
>> Type 	Name 	Deployed As 	State 	Actions
>> Connection Factory 	jms/mycon 	Server-wide 	running 	
>> Queue 	jms/myqueue 	Server-wide 	running 	
>>
>> ( One question at this point, how can I delete a "JMS Resource  
>> Groups"
>> entry like the one I created? )
>>
>>
>> Running, I receive the following exception:
>>
>> Caused by: javax.naming.NotContextException: jms/mycon
>>        at
>> org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContex
>> t.java:167)
>>        at
>> org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContex
>> t.java:603)
>>        at javax.naming.InitialContext.lookup(InitialContext.java:351)
>>        at
>> com.megasis.utils.jms.LoggingFacade.postMessage(LoggingFacade.java:17
>> 6)
>>        ... 21 more
>>
>>
>> I'm missing something, probably, and I can't find any good  
>> tutorials on
>> how to setup JMS without using MDB ...
>>
>> Any help appreciated.
>>
>> Thanks
>>
>
> -- 
> View this message in context: http://www.nabble.com/JMS-config-and-use-under-geronimo-tp18875397s134p18889658.html
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>


Mime
View raw message