Showing posts with label WSO2. Show all posts
Showing posts with label WSO2. Show all posts

Wednesday, October 7, 2015

How to enable Email as the user name in WSO2 Products


Let us see how to enable email to be used as the user name in WSO2 Products. This feature by default is disabled which can be enabled with ease. For this example I will be using WSO2 Message Broker.


Step 1 - Download and extract the WSO2 MB product


Step 2 - Change configuration in carbon.xml


Open the carbon.xml which can be found under <WSO2MBHOME>/repository/conf/carbon.xml. Un-comment the below section,

<!--EnableEmailUserName>true</EnableEmailUserName-->


Step 3 -  Change configuration in user-mgt.xml


Replace,
 <Property name="UsernameJavaRegEx">^[^~!#$;%^*+={}\\|\\\\&lt;&gt;,\'\"]{3,30}$</Property>
with - 
 <Property name="UsernameJavaRegEx">[a-zA-Z0-9@._-|//]{3,30}$</Property>

Now lets set up the admin account with a email address,

                 <AdminUser>
                     <UserName>jason@yopmail.com</UserName>
                     <Password>123123</Password>
                </AdminUser>

Step 4 - Login to management console


Start message broker by issuing the command <WSO2MBHOME>/bin/wso2server.sh start  if you are using linux distro or <PRODUCT_HOME>\bin\wso2server.bat if you are on windows and navigate to https://localhost:9443/carbon. Now you can login to console with the above credentials.

Sunday, July 26, 2015

How to use Apache JMeter as a JMS client to publish and subscribe messages with WSO2 Message Broker


In this blog post I will describe how to use Apache JMeter to publish and subscribe to a queue via WSO2 Message Broker.


Step 1 -  Download Apache JMeter

Download Apache JMeter from the link and extract it to a desired folder.

Step 2 - Download and start WSO2 Message Broker


Download WSO2 Message Broker from the link and extract it to a desired folder. Then start the Message Broker by WSO2_MB_HOME/bin wso2server.sh or wso2server.bat file depending on the OS you are running on.

Step 3 - Add required client libraries

In order to use JMeter to pub / sub via WSO2 MB we need to add couple of jar files to JMeter. Go to WSO2_MB_HOME/client-libs and copy the below libraries to JMETER_HOME/lib folder.

  1. andes-client-2.6.0.jar
  2. geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
  3. slf4j-1.5.10.wso2v1.jar
  4. log4j-1.2.13.jar
  5. org.wso2.carbon.logging-4.4.1.jar
  6. org.wso2.securevault-1.0.0-wso2v2.jar

Step 4 - Create a JNDI


To use WSO2 MB you need to create a jndi.properties file in order to create the connection. Refer below image to create a sample jndi property file. 


  1. Connection factory - give the user name and password ( admin is default user name and password ) and the IP of the broker.
  2. Give a queue name, in the example I have used the queue name is "QueOne"



jndi.properties



Step 5 -  Create a JMS Subscriber from JMeter to consume messages


Now start JMeter by navigating to JMETER_HOME/bin and run jmeter.sh / jmeter.bat depending on your OS.
To create a test plan first add a thread group and then right click on the thread group and from "Sampler" section add "JMS Subscriber".

Then fill the sampler as follows,
  1. Initial Context Factory -  org.wso2.andes.jndi.PropertiesFileInitialContextFactory
  2. Provider URL - /home/jasons/Softwares/Jmeter2/apache-jmeter-2.9/wso2mb/jndi.properties (Path to created jndi)
  3. Connection Factory - QueueConnectionFactory
  4. Destination - QueueOne

JMS Subscriber

After creating the subscriber run the subscriber ones and stop the subscriber this will create the queue in the WSO2 message broker(Note that you can manually create a queue from the Message Broker management console too)

Step 6 -  Create a JMS Publisher  

To create a publisher you can do so by creating a thread group and then from "Sampler" section add "JMS Publisher" sampler.

  1. Initial Context Factory -  org.wso2.andes.jndi.PropertiesFileInitialContextFactory
  2. Provider URL - /home/jasons/Softwares/Jmeter2/apache-jmeter-2.9/wso2mb/jndi.properties (Path to created jndi)
  3. Connection Factory - QueueConnectionFactory
  4. Destination - QueueOne
  5. Message - Provide a file or text message I have used a text messge for this example

JMS Publisher



After creating the publisher add a desired number of message count to be published this can be set from "loop count" which is located under the "Thread Group" JMeter which will publish x number of messages. For my example I have set it to 100.

Step 7 - View published message stats in Message Broker


Login  to Message Broker Management console  by going to https://localhost:9443/carbon/ provide user name and password as admin. Then you can navigate to Queues section and view the published messages and queue details.


WSO2 Message Broker console


Now run the Subscriber and the messages that was published will be consumed. You can view the details via JMeter buy adding a desired listener to examine the message status etc.


Sunday, July 19, 2015

How to browse the H2 database management tool in WSO2 products

Hi, in this blog post I shall show you how to access and view the H2 DB management tool that is shipped with all WSO2 products.


This can be easily done by following the below steps.

Step 1 - Download a WSO2 product


For this example I am using WSO2 ESB but this configuration is common to most WSO2 products which can be downloaded from here.

Step 2 - Go to carbon.xml


Extract the downloaded product to a desired location and open the carbon.xml which is located at <ESB_HOME>/repository/conf.

Step 3 - Edit the carbon.xml


Un-comment H2 DB configuration as shown below.

<!--H2DatabaseConfiguration>
        <property name="web" />
        <property name="webPort">8082</property>
        <property name="webAllowOthers" />
        <!-- <property name="webSSL" />
        <property name="tcp" />
        <property name="tcpPort">9092</property>
        <property name="tcpAllowOthers" />
        <property name="tcpSSL" />
        <property name="pg" />
        <property name="pgPort">5435</property>
        <property name="pgAllowOthers" />
        <property name="trace" />
        <property name="baseDir">${carbon.home}</property> -->
    </H2DatabaseConfiguration-->

Now start the ESB from wso2server.sh / wso2server.bat depending on the OS you are using which is located at  <ESB_HOME>/bin




Step 4 - View H2 DB Management tool in browser 

Open the browser and go to http://localhost:8082/ and give the JDBC URL which is similar to <ESB_HOME>/repository/database/WSO2CARBON_DB and test the connection. 





When it displays successful. Then click on "Connect"

You can see the databases and query it as you like.