cancel
Showing results for 
Search instead for 
Did you mean: 

Create EJB for JMS

Former Member
0 Kudos

Hi

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

can some1 explain me how to do it ?

thx,Shai

MQConnectionFactory factory = new MQConnectionFactory();

factory.setQueueManager("QM_host")

MQQueue destination = new MQQueue("default");

destination.setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);

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);

producer.send(message);

}

connection.close();

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.

regards,

Dion

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="http://help.sap.com/saphelp_erp2005vp/helpdata/en/22/cf4e71c46cdb4da31153be96c5389f/frameset.htm">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.

HTH

Peter