Hello all-
I was interested in the JCA opinion on the following:
If I am using a straight JMS connection factory (no JCA) then the following code done in a
tight loop is clearly an antipattern:
| :begin
|
| Connection conn = cf.createConnection();
|
| Session sess = conn.createSession(...);
|
| MessageProducer prod = sess.createProducer();
|
| prod.send(sess.createMessage()));
|
| conn.close();
|
| loop begin
|
Since it will be creating a new connection, session etc for every message sent which would
be incredibly slow.
However when using JCA the above becomes the "recommended" pattern of usage from
within a managed environment (ejb/servlet/mbean) since JCA caches the connection and
session so new ones don't actually necessarily get created.
Ok, this is all pretty basic stuff.
But what about the following:
| :begin
|
| Connection conn = cf.createConnection();
|
| Session sess = conn.createSession(...);
|
| MessageConsumer cons= sess.createConsumer(...);
|
| Message m = cons.receive(1000);
|
| conn.close();
|
| loop begin
|
|
For straight JMS the above would again be clearly an antipattern.
But what about JCA? It's my understanding that JCA does not cache jms consumers so
every call to createConsumer() in the above is going to result in a new consumer being
created on the jms provider. I.e. a heavyweight operation.
Would you consider the above to be an antipattern when using JCA? (I.e. using a managed
cf)
If users want to receive a JMS message in the context of a distributed transaction using
JCA1.5, then what is the recommended way of doing this?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4019580#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...