-
1. Re: how to get the managed jms connectionfactory outside the
yxyang Jul 9, 2004 7:13 AM (in response to yxyang)Hello,
In my JMX bean, i did the following testing:
Object o1 = ctx.lookup("java:/ConnectionFactory");
Object o2 = ctx.lookup("java:/Jms");
log.debug("" + (o1 instanceof QueueConnectionFactory));
log.debug("" + (o2 instanceof QueueConnectionFactory));
The results show that both o1 and o2 are instanceof QueueConnectionFactory. But i cannot use o2 to create QueueConnection:
((QueueConnectionFactory)o1).createQueueConnection();
((QueueConnectionFactory)o2).createQueueConnection();
The second creation throws exception :
java.lang.IllegalStateException: This method is not a
pplicatable in JMS resource adapter
How to use pooled connection outside the ejb?
Please help!
Thanks a lot
yang -
2. Re: how to get the managed jms connectionfactory outside the
adrian.brock Jul 9, 2004 11:21 PM (in response to yxyang)As per the FAQ:
cf = (QueueConnectionFactory) ctx.lookup("java:/JmsXA"); -
3. Re: how to get the managed jms connectionfactory outside the
yxyang Jul 10, 2004 10:11 AM (in response to yxyang)Hi,
Thanks for andrian. I read through the FAQ for several times, i still cannot find which is directly related my question :(.
The QueueConnectionFactory got by ctx.lookup("java:/Jms") cannot be used to createQueueConnection:
((QueueConnectionFactory)ctx.lookup(""java:/Jms")).createQueueConnection();
Becaue an IlleagleStateException will be thrown.
Why? Please help.
To understand the reason, i read somthing about JCA architecture.
(1) I guess that the ConnectionFactory (result of ctx.lookup("java:/Jms")) should be the ConnectionFactory refered to by application instead of ManagedConnectionFactory. Am i right?
(2) If yes, then according to the JCA requirement: "When a resource adapter creates a connection factory, it must associate the connection factory object to a ConnectionManager.". I am wondering whether the connectionfactory i got through this JNDI lookup is not assocated with a connection manager (which should be implemented by application server)?
(3) If yes, then how can i associate the connectionfactory got through JNDI looking up with a Connection Manager?
(4) Or i am totally wrong?
Please help.
best regards
yang -
4. Re: how to get the managed jms connectionfactory outside the
stephanenicoll Jul 11, 2004 6:25 AM (in response to yxyang)(4) read Adrian's post one more time. The name is java:/JmsXA not java:/Jms ...
Regards,
Stephane -
5. Re: how to get the managed jms connectionfactory outside the
stephanenicoll Jul 11, 2004 6:25 AM (in response to yxyang)Also, the Wiki contains code that shows how to use java:/JmsXA with XDoclet in a Session Bean.
http://www.jboss.org/wiki/Wiki.jsp?page=JmsSenderBean -
6. Re: how to get the managed jms connectionfactory outside the
yxyang Jul 11, 2004 7:25 AM (in response to yxyang)hi
I think StephaneNicoll misunderstand my question.
It is not the issue of java:/JmsXA or java:/Jms.
I also know how to use resource adapter in ejb by define entries in ejb-jar.xml file etc.
My question is how to use resource adapter outside of ejb? e.g., like JMX bean.
Andrian, can you give me help?
thanks a lot
yang -
7. Re: how to get the managed jms connectionfactory outside the
stephanenicoll Jul 11, 2004 7:55 AM (in response to yxyang)Well I might misunderstand your question, true, but back to your first post:
QueueConnectionFactory qf = (QueueConnectionFactory) ctx.lookup("java:/JmsXA");
qf.createQueueConnection();
will work in your Mbean. Then you can do whatever you want with the connection (returns it to the caller for instance eventhough I don't really get the point)
Regards,
Stephane -
8. Re: how to get the managed jms connectionfactory outside the
yxyang Jul 11, 2004 8:59 PM (in response to yxyang)In my previous post, it is clearly written that it will throws
IllegalStateException
This is the reason why i post here.
Regards
yang -
9. Re: how to get the managed jms connectionfactory outside the
yxyang Jul 11, 2004 9:36 PM (in response to yxyang)Hi
This is my codes:
QueueConnectionFactory qcf = (QueueConnectionFactory)ctx.lookup("java:/JmsXA");
QueueConnection qc = qcf.createQueueConnection();
qc.setExceptionListener(this);
ERROR [STDERR] (ScannerThread:com.test:service=C2SConnector C2SConnectorService) java.lang.IllegalStateException: This method is not applicatable in JMS resource adapter
ERROR [STDERR] (ScannerThread:com.test:service=C2SConnector C2SConnectorService) at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.setExceptionListener(JmsSessionFactoryImpl.java:213)
I read the source code of JmsSessionFactoryImpl.java
The code at line 213 is:
public void setExceptionListener(ExceptionListener listener)
throws JMSException
{
throw new IllegalStateException(ISE);
}
I don't know how to solve this problem.
Andrian, please give me help.
Thanks a lot
yang -
10. Re: how to get the managed jms connectionfactory outside the
darranl Jul 12, 2004 11:35 AM (in response to yxyang)"yxyang" wrote:
In my previous post, it is clearly written that it will throws
IllegalStateException
No it isn't your posts you never say that you used 'java:/JmsXA' -
11. Re: how to get the managed jms connectionfactory outside the
yxyang Jul 12, 2004 11:26 PM (in response to yxyang)It is ok, it is the problem of java:/JmsXA or java:/Jms.
Because i just change the name JmsXA to Jms. Ok, you just assume that it java:/JmsXA.
Actually, i just modified the jndi name to java:/Jms and also modify other place e.g., login....xml etc. It is not related to this.
I tested both java:/Jms and java:/JmsXA.
Within EJB, it works fine. But outside EJB(in my case, it is a JMX bean), the IllegalStateException is thrown.
regards
yang -
12. Re: how to get the managed jms connectionfactory outside the
adrian.brock Jul 14, 2004 12:42 AM (in response to yxyang)You cannot set an ExceptionListener on a JCA managed JMS connection.
The ExceptionListener is handled internally by the JMS resource adapter.
Using a JCA JMS pool, you never deal with a single connection, the connection is
pooled. -
13. Re: how to get the managed jms connectionfactory outside the
bensonfungjava Apr 20, 2005 11:37 PM (in response to yxyang)Hi Adrian,
I still don't understand your answer. I am sorry. :~(
Benson