[jboss-user] [JBoss Messaging] - help on JmsXA
mattlf
do-not-reply at jboss.com
Mon Jun 23 22:40:52 EDT 2008
Hi
I am new to jboss messaging and i apologize if my question turns out to be silly.
I have a sender that createConnection, createSession and createProducer on every message. I am concerned this is very inefficient. I read on some other posts that it is acceptable if one uses JmsXA
| public class JmsPublisher
| {
|
| private ConnectionFactory bizConnectionFactory ;
| private Destination bizDestination;
|
|
| public ConnectionFactory getBizConnectionFactory() {
| return bizConnectionFactory;
| }
| public void setBizConnectionFactory(ConnectionFactory bizConnectionFactory) {
| this.bizConnectionFactory = bizConnectionFactory;
| }
| public Destination getBizDestination() {
| return bizDestination;
| }
| public void setBizDestination(Destination bizDestination) {
| this.bizDestination = bizDestination;
| }
|
| public JmsPublisher(){}
|
| public void sendEvent(SignalAbstract ev)
| throws
| JMSException
| {
| Connection connection = null;
| Session session = null;
| MessageProducer messageProducer = null;
|
| try
| {
|
| connection = bizConnectionFactory.createConnection();
| session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
| messageProducer = session.createProducer(bizDestination);
|
| ObjectMessage msg = session.createObjectMessage(ev);
|
| messageProducer.send(msg);
|
| }
| finally
| {
| if (messageProducer != null) try { messageProducer.close(); } catch (Exception ignore) { }
| if (session != null) try { session.close(); } catch (Exception ignore) { }
| if (connection != null) try { connection.close(); } catch (Exception ignore) { }
|
| }
|
| }
|
| }
|
I inject the jndi name via Spring
| <jee:jndi-lookup id="bizConnectionFactory"
| jndi-name="${biz.messagingConnectionFactoryName}">
| <jee:environment>
| java.naming.provider.url=${biz.messagingProviderUrl}
| java.naming.factory.url.pkgs=org.jnp.interfaces:org.jboss.naming
| java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
| </jee:environment>
| </jee:jndi-lookup>
|
| <jee:jndi-lookup id="bizDestination"
| jndi-name="${biz.messagingDestinationName}">
| <jee:environment>
| java.naming.provider.url=${biz.messagingProviderUrl}
| java.naming.factory.url.pkgs=org.jnp.interfaces:org.jboss.naming
| java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
| </jee:environment>
| </jee:jndi-lookup>
|
| <bean class="com.strateer.biz.impl.JmsPublisher"
| id="bizJmsPublisher">
| <property name="bizConnectionFactory" ref="bizConnectionFactory" />
| <property name="bizDestination" ref="bizDestination" />
| </bean>
|
It works when
| biz.messagingProviderUrl=localhost:1099
| biz.messagingConnectionFactoryName=ConnectionFactory
|
but it doesn't when i change the connectionFactoryName to java:/JmsXA
| biz.messagingProviderUrl=localhost:1099
| biz.messagingConnectionFactoryName=java:/JmsXA
|
The logs say the following:
Error creating bean with name 'bizConnectionFactory': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: JmsXA
And i don't seem to be able to get it working.
I would appreciate some tips
Thank you for your help
matt
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4160080#4160080
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4160080
More information about the jboss-user
mailing list