Monday, December 21, 2009

WebSphere JMS Sample Application

My previous blog I outlined the steps required to configure JMS resources for WebSphere Application Server 7.0. In that blog I promised to put together a sample application that can be installed to WebSphere Application Server and demonstrates three different implementations of sending JMS messages to a queue and retrieving the messages from a queue. The sample application is an Eclipse project interchange file. If you have Rational Application Developer installed on your computer you should be able to import this project into your workspace without too much hassle. Alternatively you can always use your favourite decompression tool to extract the contents to your local drive and then view the source from there.

Below are two diagrams describing the JMS runtime resources configured for the sample application:

Programmatic / Spring implementation



EJB3 implementation



Web client
To test the application I created a very simple web application that is used to trigger the sending of a JMS text message to a queue as well as to retrieve the message from the queue. I decided to use the Spring MVC  web framework to keep things simple. Below is a screen shot of the jms-tester web page:




Wednesday, December 9, 2009

WebSphere SIB, JMS queues and connection factory configuration

I was recently given a task to migrate an enterprise application that was running on SAP NetWeaver across to WebSphere application server. The application had a few session beans as well as a few message-driven beans. It used JMS to publish messages to a number of queues. This blog entry outlines the steps I took to configure the JMS queues and connection factories on WebSphere. It is pretty plain and boring but is really for my own benefit to be used as a reference and who knows maybe if you are reading this it may come in handy as well.

The following configurations were done on a single server of WebSphere application server 7.0. It assumes that the user is logged into the administration console and where global security has been enabled:

Create J2C authentication user
  • Security -> Global security -> Expand Java Authentication and Authorization Service -> J2C authentication data -> New
  • Enter in the following values:
    • Alias: myusr
    • User ID: myusr
    • Password: myusr
  • Click the OK button
  • Save to the master file configuration

Create group
  • Users and Groups -> Manage Groups -> Create
  • Enter in the following values:
    • Group name: mygrp
  • Click on the Group Membership button
  • Add the mygrp
  • Click the close button

Create user
  • Users and Groups -> Manage Users -> Create
  • Enter in the following values:
    • User ID: myusr
    • First name: Myusr
    • Last name: Mysurname
    • Password: mypassword
    • Confirm password: mypassword
  • Click on the Group Membership button
  • Click the Search button
  • Add the mygrp
  • Click the Close button
  • Click the Create button

Create SIB
  • Service integration -> Buses -> New
  • Bus Name: my_bus
  • Bus Security: enabled
  • Press next to enter the security wizard
  • Complete the wizard by accepting all the defaults
  • Save your changes by clicking the save link

Configure Authorization for the SIB
  • Service integration -> Buses
  • Select the Enabled link for the my_bus
  • [Authorization Policy] -> Users and groups in the bus connector role -> New
  • Enable Groups radio button and click the Next button
  • Select the mygrp checkbox and then the Next button
  • Click the OK button
  • Save to the master file configuration

Create Bus member for SIB
  • Service integration -> Buses -> my_bus -> [Topology] Destinations -> Bus members -> Add button
    • Enable the server radio button
  • Click the Next button
    • Enable the File store radio button
  • Finish the wizard by accepting all defaults
  • Save to the master file configuration

Create destinations for SIB
  • Service integration -> Buses -> my_bus -> [Destinations resources] Destinations -> New
  • Type: Queue
  • Next
  • Identifier: myFirstD
  • Select the bus member you created in the previous step
  • Finish the wizard by accepting all defaults
  • Save to the master file configuration

Configuring authorization on queue destinations
Optional because already has AllAuthenticated by default however it is recommended to remove this and add your own
  • Service integration -> Buses
  • Select the Enabled link for the my_bus
  • [Authorization Policy] -> Manage destination access roles
  • Select the myFirstD destination
  • Select the Add button
  • Enable Groups radio button and click the Next button
  • Select the mygrp checkbox and then the Next button
  • Check the Sender, Receiver and Browser checkboxes
  • Click the Finish button
  • Click the OK button
  • Save to the master file configuration

Create Connection Factory (Can also create Queue / Topic Connection Factory in a similar way)
  • Resources -> JMS -> Connection factories -> select server scope from the drop down list -> New
  • Default messaging provider -> Next
  • Enter in the following values:
    • Name: MyConnectionFactory
    • JNDI name: jms/MyConnectionFactory
    • Bus name: my_bus
    • Container-managed authentication alias: myusr
  • Click the OK button
  • Save to the master file configuration

Create JMS Queues (Can also create Topics in a similar way)
  • Resources -> JMS -> Queues -> select server scope from the drop down list -> New
  • Select the Default messaging provider radio button
  • Click the OK button
  • Enter in the following values:
    • Name: myFirstQ
    • JNDI name: jms/myFirstQ
    • Bus name: my_bus
    • Queue name: myFirstD
  • Select the OK button
  • Save to the master file configuration

Create Activation specifications
  • Resources -> JMS -> Activation specifications -> select server scope from the drop down list -> New
  • Select the Default messaging provider radio button
  • Click the OK button
  • Enter in the following values:
    • Name: myFirstSpec
    • JNDI name: eis/myFirstSpec
    • Destination type: Queue
    • Destination JNDI name: jms/myFirstQ
    • Bus name: my_bus
    • Authentication alias: myusr
  • Select the OK button
  • Save to the master file configuration

That's all there is to it. The next step will be configuring you application's resources and assigning them the correct authentication methods. I will describe those steps in my next blog along with a sample application.