Red Hat APPLICATION SERVER - JONAS Manual page 217

Jonas
Hide thumbs Also See for APPLICATION SERVER - JONAS:
Table of Contents

Advertisement

Chapter 26. JMS User's Guide
}
This method sends a message containing its String argument.
26.6.2. The Entity Bean
The example uses the simple Entity Bean Account for writing data into a database. Refer to the sample
eb, which is described in Chapter 2 Getting Started with JOnAS and in the JOnAS Tutorial.
26.6.3. The Client Application
The client application calls the sendMsg method of the EjbComp bean and creates an AccountImpl
Entity Bean, both within the same transaction.
public class EjbCompClient {
...
public static void main(String[] arg) {
...
utx = (UserTransaction)
initialContext.lookup("javax.transaction.UserTransaction");
...
home1 = (EjbCompHome) initialContext.lookup("EjbCompHome");
home2 = (AccountHome) initialContext.lookup("AccountImplHome");
...
EjbComp aJmsBean = home1.create();
Account aDataBean = null;
...
utx.begin();
aJmsBean.sendMsg("Hello commit"); // sending a JMS message
aDataBean = home2.create(222, "JMS Sample OK", 0);
utx.commit();
utx.begin();
aJmsBean.sendMsg("Hello rollback"); // sending a JMS message
aDataBean = home2.create(223, "JMS Sample KO", 0);
utx.rollback();
...
}
}
The result of this client execution will be that:
The
"Hello commit"
be created in the database (corresponding to the Entity Bean
The
"Hello rollback"
record will not be created in the database (since the Entity Bean
26.6.4. A Pure JMS Client for Receiving Messages
In this example, the messages sent by the EJB component are received by a simple JMS client that is
running outside the JOnAS server, but listening for messages sent on the JMS topic "sampleTopic." It
uses the ConnectionFactory automatically created by JOnAS named "JCF".
public class MsgReceptor {
static Context ictx = null;
message will be sent and the
message will never be sent and the
[222, 'JMS Sample OK', 0]
creation).
109
[223, 'JMS Sample KO', 0]
creation will be canceled).
110
209
record will

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the APPLICATION SERVER - JONAS and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Application server

Table of Contents