Showing results for 
Search instead for 
Did you mean: 

Create EJB for JMS

Former Member
0 Kudos


I want to use this IBM Code as an EJB in NWDS

can some1 explain me how to do it ?


MQConnectionFactory factory = new MQConnectionFactory();


MQQueue destination = new MQQueue("default");


Connection connection = factory.createConnection();

Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

MessageProducer producer = session.createProducer(destination);

String groupId = "ID:" + new BigInteger(24 * 8, new Random()).toString(16);

for (int i = 1; i <= 5; i++) {

TextMessage message = session.createTextMessage();

message.setStringProperty("JMSXGroupID", groupId);

message.setIntProperty("JMSXGroupSeq", i);

if (i == 5) {

message.setBooleanProperty("JMS_IBM_Last_Msg_In_Group", true);


message.setText("Message " + i);




Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Shai,

You could create a session bean in NWDS and import your MQ packages. Then define a method in your ejb that executes the code.



Former Member
0 Kudos

Hi Shai,

Packing all the MQ classes inside the application is one possible option, however in that way the it will not be integrated properly - for example there would be no way to make the EJB transaction commit together with the JMS one, as pet the J2EE specification, you also won't be able to use the monitoring and administration options of the SAP Web AS.

The recommended way is to use only the JMS API in your application (javax.jms.*) and then use the JMSConnector service to configure the access to your external JMS-es :

<a href="">JMSConnector doc</a>

later you will be able to switch to whatever JMS infrastructures (SAP JMS, jboss, etc.) without redeploying your application, just by changing the configuration settings.