webMethods Blog - webMethods as JMS Provider
Jun 01, 2012 13:59 2 Comments Messaging Raj Kumar

webMethods Broker as JMS Provider 



Using MWS


Go to MWS->Administration->Messaging->Broker Servers->Broker ->Adding New Broker for JMS (Not required, default one also can be used)




Go to MWS->Administration->Messaging->Naming Directories->Providers to ADD JMS  Provider 

Give Provider Name, Provider URL 

Client Group as admin, other custom client group can also be used (provide enough permission to the client group created)




Go to MWS->Administration->Messaging->Naming Directories->Connection Factories to ADD Connection Factory


Give Lookup Name, Connection Factory Type, Broker, client group…



Go to MWS->Administration->Messaging->Naming Directories->Destination to ADD destination (Topic/Queue)




Add the created Destination to Document Types

 Go to MWS->Administration->Messaging->Broker Servers->Document Types->ADD Topic under ESB Broker




Go to MWS->Administration->Messaging->Broker Servers->Client Groups->Add Document Types for admin client group under ESB Broker

Broker::Activity: EventTypeChange

SAG_JMS: Topic



Write Simple Java Client Program to Test  (Sender) 



package jms_wM; 

import java.util.Properties;

import javax.jms.*;

import javax.naming.*; 

public class SampleSender {     


      public static void main(String[] args) { 


              //creating properties file for getting initial context

              Properties env = new Properties(); 

              env.setProperty("java.naming.factory.initial", "com.webmethods.jms.naming.WmJmsNamingCtxFactory");              env.setProperty("java.naming.provider.url", "wmjmsnaming://ESB@" ); 

env.setProperty("com.webmethods.jms.naming.clientgroup", "admin"); 

        Context namingContext = new InitialContext(env);  //using the properties file to create context 

    System.out.println("Context Created"+ namingContext.toString());       

           //Lookup Connection Factory

        TopicConnectionFactory conn = (TopicConnectionFactory) namingContext.lookup("SAG_JMSTopicConnectionFactory");

           System.out.println("Lookup Connection Factory Success"+ conn.toString());

  Connection connection = conn.createConnection();  //Create Connection  


         System.out.println("Connection Created"+ connection.toString()); 

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

        Destination dest = (Topic) namingContext.lookup("SAG_JMSTopic");  //Lookup Topic/Queue to create Destination

 System.out.println("Destination Created"+ dest);


MessageProducer producer = session.createProducer(dest);  //Create Message Producer       


        TextMessage msg = session.createTextMessage();  //Create Message

                    msg.setText("Im here"); 

        producer.send(msg);  //Send Message       


        System.out.println("Message Send to Topic Successfully"); 

      }catch(Exception e){System.out.println(e.toString());}



Import Required Jar Files



Set the Class Path for wm-jmsnaming.jar and wm-brokerclient.jar in the client machine if required (Check 8-0-SP1_Broker_Messaging_Programmers_Guide for more details)


Test the java program to see the results


Check in MWS for Docs Published under the topic SAG_JMS::Topic


In the same way java client program can be written to subscribe from the topic/ IS can be made as client to test.

Connection Factory, Topic, Brokers etc can also be created using JMSAdmin tool from command prompt like (Check 8-0-SP1_Broker_Messaging_Programmers_Guide for more details)



D: SoftwareAGBrokerin>jmsadmin -p jndi.properties

Connected to JNDI Context: Broker::JmsNaming::JmsAdminTest

/ > bind cf aSenderFactory with group=SampleSenders

/ > bind cf aReceiverFactory with group=SampleReceivers

/ > bind topic aTopic with topicName=Samples::RequestInfo

/ > connect

Connected to Broker #1 on localhost:6849

/ > create topic for aTopic

/ > create group SampleSenders

/ > permit group SampleSenders to publish Samples::RequestInfo

/ > create group SampleReceiver

/ > permit group SampleReceiver to subscribe Samples::RequestInfo

/ > end

Prev Next
About the Author
Topic Replies (2)
  1. 1
    idnkx user


    Hi Team , Why linked image file is not visible.

    idnkx user

    Tery heigh

    Hi Raj, thx for the tut but why am i getting this? [b]java.lang.ClassCastException: com.webmethods.jms.impl.WmConnectionFactoryImpl cannot be cast to javax.jms.TopicConnectionFactory[/b]

Leave a Reply
Guest User

You might also like

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.

Let`s Connect