Robert Parlett wrote:
Hello

I'm having a problem with using Joram JMS from inside an
EJB.

I specify several topics in my jonas.properties file.  The
JMS server is co-located.

The EJB looks up "XATCF1" from JNDI (for
portability/flexibility I am not using the java:comp/env
lookup method), and sends a message to a topic.  The client
on another machine looks up "JTCF" also from JNDI, and
listens for a message on the topic.

If I use non-transactional messages, everything works fine,
except of course the messages are sent regardless of whether
the transaction succeeds.

If I change to use transactional messages, by specifying
true in the TopicConnection.createTopicSession() method,
then the messages are never received by the client.  It
seems as though Joram is missing the commit() stage and
never really sending them out.

I'm using Jonas 2.4.

Any suggestions would be much appreciateed.

Thanks.

R Parlett.
 


Hi Robert,
In your mail I understand that if you set the the transacted flag to true in
TopicConnection.createTopicSession in the sender (which is an EJB component) your are not able
to received messages in a pure JMS client which is a message receptor.
Have I well understood your problem? if yes it is strange.
In fact the parameter transacted is never taken into account in create<Queue|Topic>Session
when this method is called within an EJB (look at the JOnAS Documentation,
the § transactions and JMS sessions within an EJB component in EJB/JMS User's Guide
http://www.objectweb.org/jonas/jonas_root/doc/PG_EjbJmsGuide.html)
It is said in this §:

  • If the session creation occurs outside of a transaction, the parameters will be considered as being transacted =  false and acknowledgeMode = AUTO_ACKNOWLEDGE. Which means that each operation of the session is immediately executed (the session is not transacted, it could not be since the use of commit and rollback JMS  session methods is not allowed within an EJB).
  • If the session creation occurs inside a transaction, the parameters have no meaning, the session may be considered as transacted, the commit and rollback operations being handled by the EJB server at the level of the associated XA resource.
You can make the following tries with the example jms which is under $JONAS_ROOT/examples/src/jms:
In this example, the EJB component EjbCompBean sends messages to a topic in the sendMsg method,
 Messages are received in a JMS Client MsgReceptor.java.
You can see  that the session in EJBCompBean is created as :
      session = tc.createTopicSession(true, Session.AUTO_ACKNOWLEDGE);
the client of this bean EjbCompClient sends two messages  inside transactions
      utx.begin();
      aJmsBean.sendMsg("Hello commit");
      utx.commit();
and :
      utx.begin();
      aJmsBean.sendMsg("Hello  rollback");
      utx.rollback();

The transactional attribute associated to the sendMsg   method is Required
You can see in the xterm in which the MsgReceptor  is launched that only the first message is received.
 In sendMsg the session is created in the scope of a transaction so a transacted session is created.
If you change true by false in createTopicSession the result is the same conforming to what is said in
the documentation.
If you change the transaction attribute for EjbCompBean  from Required to NotSupported  (in EjbComp.xml)
you  will see that now both messages are received, because as the session was created outside
the scope of a transaction a non transacted session has been created ans each send is immediately executed.

It seems that this is quite similar to the tests you have made and for me it is running correctly.

I hope it helps,
Best regards

-- 
        Philippe

Philippe Coq  Evidian   Phone: (33) 04 76 29 78 49
Bull S.A  - 1 rue de Provence - 38432 Echirolles Cedex France
Download our EJBServer at http://www.objectweb.org
 

----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".


Reply via email to