geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zm <zzzz_m...@hotmail.com>
Subject Re: JMS config and use under geronimo
Date Fri, 08 Aug 2008 10:39:18 GMT

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>
        <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 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)

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?) ?


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