Posted on

Configuring JMS endpoints with WebSphere MQ

websphere mq configuring jms destinations

Configuring JMS endpoints with WebSphere MQ

You can configure both the Queue and Topic destinations for the WebSphere MQ messaging provider. In this section, we introduce how to create and configure a WebSphere MQ Queue destination. To configure a Queue destination for the WebSphere MQ messaging provider, complete the following steps:

  1. Click Resources > JMS> Queues. In the Queues window, click Scope (we will use Server scope in this sample), and then click New.
  2. Select the WebSphere MQ messaging provider option, and enter the following basic properties:

 websphere mq configuring jms destinations

Click OK. The new Queue is created. Save the changes to the master configuration.

Posted on

Configuring Websphere MQ

configuring websphere mq message broker

Configure Websphere MQ Messaging Provider

The WebSphere MQ JMS provider maps to the WebSphere MQ messaging system which is one of the most widely used message-oriented-middleware (MOM) product in the industry. It has been available for many years and is widely used to integrate applications on disparate platforms. The key runtime artifact in WebSphere MQ is called a Queue Manager.

Since WebSphere MQ is not part of WebSphere Application Server, its Queue Managers run in separate processes and are separately administered through the WebSphere MQ Queue Manager.

In order to proceed with Websphere MQ configuration, you need to download a trial of it at: http://www-947.ibm.com/support/entry/portal/downloads/software/websphere/websphere_mq\

Create Websphere MQ basic objects

In order to connect to WebSphere MQ messaging provider we will show at first how to create some basic MQ objects. The following commands can be executed from the MQ_HOME/bin folder.

To create a new Queue Manager called MQQueueManager issue the following command:

crtmqm MQQueueManager

Now start the Queue Manager named MQQueueManager by typing the following command:

strmqm MQQueueManager

To stop the Queue Manager enter the following command:

endmqm MQQueueManager

In order to create a new Queue definition for the MQQueueManager, you need to use the runmqsc command which takes its input from stdin, thus you will enter your command interactively.

So, in order to create a Queue definition using MQ scripting, enter the following commands:

runmqsc MQQueueManager  define qlocal(SampleMQ)  end

Now create a listener for your Queue by entering the following commands:

runmqsc MQQueueManager  DEFINE LISTENER(MQQueueManager.listener) TRPTYPE (TCP) PORT(1424)  START LISTENER(MQQueueManager.listener)  end

Finally, restart the QueueManager for your commands to take effect:

endmqm MQQueueManager  strmqm MQQueueManager

Configuring a Connection Factory with WebSphere MQ

To configure a JMS connection factory for the WebSphere MQ provider, choose Resources> JMS> Connection factories. In the Connection factories window, select the Scope of your resource and then click “New”.

configuring websphere mq message broker 

In the next step select the WebSphere MQ messaging provider option,

configuring websphere mq message broker 

Click OK. This will take you to the Step 1 wizard where you need to enter the Name for the Connection Factory and the JNDI name that binds it to the name space.

configuring websphere mq message broker 

Click Next to continue. In the Step 2, you should determine how to connect to Websphere MQ. Choose “Enter all the required information into this wizard “option, as shown:

configuring websphere mq message broker 

Click Next to continue. In the Step 2.1 you need to supply the Queue Manager or Queue sharing group name you wish to connect to. (see the paragraph “Create Websphere MQ basic objects” )

configuring websphere mq message broker 

Click Next. In the Step 2.2 choose the transport type and specify the host and port of the MQ Queue Manager. The port must match the listener port that you defined for the Queue Manager.

configuring websphere mq message broker 

Click Next. You can check your connection by clicking on the Test connection to verify that you can connect to the WebSphere MQ Queue Manager. In the Summary window, review your configuration, then click Finish and Save.

Posted on

Configuring JMS endpoints with the default provider

configure jms destination websphere broker

Configuring JMS Destination on Websphere application server

You can configure both Queue and Topic destinations for the default messaging provider. Creating a JMS destination using the default messaging provider is a two process step which requires

  • Registering the JMS destination on the Bus
  • Definition of the JMS destination (and its binding) as WAS Resource

Let’s see each one in detail:

Registering the JMS destination on the Bus

In the first part, we will register a JMS Queue on the Bus by completing the following steps:

  1. Click Service integration > Buses.
  2. Then click on the JMSBus we have formerly created and navigate to Destinations link.

configure jms destination websphere broker

  1. From there, click New:

 configure jms destination websphere broker

  1. Now choose the destination type as shown by the following picture:

 configure jms destination websphere broker

  1. Next, enter an unique Identifier for the Queue destination, as shown in the picture:

 configure jms destination websphere broker

  1. In the last screen, you will assign the Queue to a Bus member. You can just leave the default values and confirm the queue creation in the last screen.

 configure jms destination websphere broker

Click OK and Save the changes to the master configuration. A new Queue name

DemoQueue has been created.

Definition of JMS destinations as WAS Resource

Once registered the JMS destination on the Bus, in order to be able to use it you need to define it as WAS Resource.

  1. From the Admin Console expand your Resources option and choose JMS > Queues.
  2. In the Queues window, choose the Scope for your destination and then click New.

 configure jms destination websphere broker

Select the Default messaging provider option and click OK:

configure jms destination websphere broker 

Complete the wizard by entering the JMS destination properties. In this example, we are binding the Demo Queue under the JNDI name “jms/demoQueue” and using the following properties:

configure jms destination websphere broker 

Click OK. The new Queue is created. Save the changes to the master configuration.

Posted on

Configuring a Connection Factory with Websphere default provider

configure jms connection factory websphere broker

We will now show how to configure a Queue Connection Factory using the default Websphere default JMS provider:

  1. Start by selecting Resources > JMS > Queue Connection factories.
  2. In the Queue Connection factories window, choose the scope, and then click New.

 configure jms connection factory websphere broker

In the next screen, you will need to associate the Connection Factory with a JMS Provider. Select “Default messaging provider

 

configure jms connection factory websphere broker 

Click OK to continue. Next you will enter the Connection Factory General Properties as shown here:

configure jms connection factory websphere broker 

The mandatory fields are the Connection Factory Name (which will be used as display name) and the JNDI name binding for the resources.

The actual list of Connection Factory properties is quite large and it’s beyond the scope of this book to discuss about them all. If you want to learn more, consult Websphere AS Messaging guide (http://www.redbooks.ibm.com/redbooks/pdfs/sg247770.pdf)

Click OK. The new connection factory is now created. Save the changes to the master configuration

Posted on

Configuring Websphere default JMS broker

websphere jms broker

This excerpt from the Enter­prise Appli­ca­tion Server Cook­Book that will teach how to configure the default JMS broker for Websphere application server.

If you want to fully understand the complex topics contained in this chapter we need to make sure that you have a basic knowledge of JMS core elements:

  • A Connection Factory is an object that a JMS client (a Java program that uses the JMS API) uses to create a connection with a JMS provider.
  • A JMS queue is a staging area that contains messages that have been sent and are waiting to be read (by only one consumer). Note that, in contrast to what the name “queue” suggests, messages don’t need to be delivered in the order sent. A JMS queue only warranties that each message is processed only once.
  • A JMS topic is a distribution mechanism for publishing messages that are delivered to multiple subscribers.

When using the default JMS provider your JMS Connection Factories will connect to a Service Integration Bus (SiBus), which hides the actual JMS implementation from the application. Applications then use queues within the SiBus to send and receive messages. At the same time, the JMS Topics are persisted in the SiBus and accessed through appropriate Connection Factories, which applications use to gain access to the Bus.

In order to create a JMS Connection Factory using the Default Provider you need at first create a Service Integration Bus which will act as a proxy between your messaging engines.

Connect to the Admin Console and choose Service Integration > Buses. Click on “New”. The new Bus wizard will start. In Step 1 enter the name of your Bus:

websphere jms broker 

If you have checked the Bus security option you will ensure that client applications authenticate to the bus and the authorization policy for the Bus is enforced. This will add some additional screen shots for specifying which security domain to use for securing your Bus. Please refer to the Chapter 11 for learning how to create a security domain).

Click on Next. In Step 2 you will be requested to confirm the creation of your Bus. Once confirmed, the Bus will be enlisted in the Bus summary page as shown by the following picture:

websphere default jms broker 

To complete the configuration of the SiBus, we must add an existing server as a member to the SiBus so that we have a facility for message persistence.

In order to do that, click on the “JMSBus” just created and, within the Topology section, click Bus members, as shown by the following screenshot:

websphere default jms broker 

You will now be presented with a screen where you can add Bus members.

By clicking Add and you will be able to select the server you wish to add as a member to the Bus. You will notice that the Server option is already pre-selected, as shown in the following screenshot:

websphere default jms broker

 

Click Next to proceed to the final screen, where you will choose the message persistence option between File store and Data store (the first one will persist your messages on a file system, the second one obviously on a database):

websphere default jms broker

The next screen will be dependent on your message store. Supposing that you have selected “File Store”, in the next step you will be able to configure the File Store properties:

websphere default jms broker

Click Next. In the following screen you will be able to tune performance parameters by choosing an appropriate JVM heap size; in the following screen we have just left the default values:

websphere default jms broker 

Clicking Next again will take you to the Summary page where you can review your configuration. Click Finish and Save to retain the changes.

You will now see the application server called server01 listed as a Bus member. At this point, the server must be restarted in order to activate the SiBus message engine. In the next recipes we can start configuring JMS resources on the top of it.

Posted on

Creating a deployable Datasource with Websphere

what is websphere websphere tutorials websphere books websphere datasource

In order to deploy resources like data sources or JMS destinations along with your applications you need to use a special format for your applications called Enhanced EAR. A WebSphere Enhanced EAR file is a regular Java EE EAR file but with additional configuration information for resources required by Java EE applications.

When an Enhanced EAR is deployed to WebSphere Application Server, the resources

specified in the Enhanced EAR are automatically configured using a pre-define scope as shown in this table:

Resource

Scope

JDBC Providers & Data sources

Application

JMS resources

Application

Resource adapters

Application

Class loaders

Application

Substitution variables

Application

Shared libraries

Server

JAAS authentication alias

Cell

Virtual hosts

Cell

If you want to create an Enhanced EAR then it’s highly suggested to use a development tool like Rational Application Developer (RAD) or IBM Assembly and Deploy Tools for Websphere.

 

You can evaluate Websphere Rational Application Developer (RAD) from the IBM site: http://www.ibm.com/developerworks/downloads/r/rad/ . If you want to develop applications using free tools, check out Chapter 7 which is about installing “IBM Websphere developer tool”.

Creating an Enhanced EAR using RAD

Once that you created an Enterprise Application Project, in order to access the Enhanced EAR deployment options, right-click the EAR project, and select Java EE  > Open WebSphere Application Server Deployment.

This will open the deployment editor containing all the enhancements you can apply on your Enterprise application (in this sample, the EAR is just made up of an EJB archive)

 

what is websphere websphere tutorials websphere books websphere datasource

 

To configure JDBC providers, expand at first the Authentication section, so that we create an authentication alias for your Connection, (remember just as we did before using the Web console).

 

what is websphere websphere tutorials websphere books websphere datasource

The Alias is just a reference name for your Authentication Entry, whose User id and Password are obviously your database credentials. Next, expand the Data Sources section. As you can see, there’s already a pre-configured JDBC provider for the Derby database. (You can remove this Entry by clicking on the Remove button).

 

what is websphere websphere tutorials websphere books websphere datasource

To configure an Oracle JDBC provider, complete the following steps:

  1. Click Add next to upper JDBC Provider list.
  2. In the window that opens, select the following options (as shown in the picture):

        Oracle as the Database type

        Oracle JDBC thin driver as the JDBC provider type

what is websphere websphere tutorials websphere books websphere datasource

 

In the next window, enter a name for the JDBC provider and check that the Class path information and Native Path both map to the location where the JDBC driver is:

 

what is websphere websphere tutorials websphere books websphere datasource

 

Now your JDBC Provider will be enlisted in the Websphere Deployment screen, as shown by the following picture:

 

what is websphere websphere tutorials websphere books

Ok, now it’s time to define your data source so move to the “Data Sources” section and click on Add. In the next screen, you will need to select the JDBC driver which will be used by the Data Source:

 

what is websphere websphere tutorials websphere books websphere datasource

 

Next, enter all the Connection details as shown by the following picture:

 

what is websphere websphere tutorials websphere books

By clicking on Finish, you should be able to see your data source enlisted in the Data Sources section along with the connection properties:

what is websphere websphere tutorials websphere books websphere datasource

Ok, now your EAR is ready to be exported into WAS along with the data source information that is contained in a file named resources.xml. If you are curious to know what an Enhanced EAR looks like, have a look into the META-INF folder of the EAR archive:

SAMPLEEJBEAR.EAR\META-INF

│   MANIFEST.MF

└───ibmconfig

    └───cells

        └───defaultCell

            │   security.xml

            │   virtualhosts.xml

            │

            ├───applications

            │   └───defaultApp

            │       └───deployments

            │           └───defaultApp

            │                   deployment.xml

            │                   resources.xml

            │                   variables.xml

            │

            └───nodes

Now deploy your application (See Chapter 8 for more information about it application deployment). Within your Enterprise Applications screen, select your application and click on the “Application scoped resources” option (contained in the References section):

what is websphere websphere tutorials websphere books

As you can see, the OracleDataSource we have configured with RAD now ships with your application and is ready for serving requests of your application.

 

Posted on

Configuring an HA Datasource with Websphere

what is websphere websphere tutorials websphere books websphere datasource

Since version 8 of WAS, you can emulate High availability of your Data Sources using Alternate data sources. You can configure alternate data sources by simply adding a custom property named alternateResourceJNDIName to your data source.  This property contains the JNDI name of the alternate data source.

Once configured, a data source and connection factory can fail over and fail back automatically when a specified or default failure threshold value is reached. When fail over occurs, the application switches from using the primary resource to using the alternate resource. Fail back occurs when the application switches back from the alternate resource to the primary resource.

To enable workload routing among data sources, complete the following steps:

1.       Click Resources >JDBC > Data sources and select your desired Data Source.

 

what is websphere websphere tutorials websphere books websphere datasource

2.       From the data source Additional properties, select the Connection pool properties link.

3.       In the Connection pool properties screen, follow the “Connection pool custom properties” link.

4.       Once in the Connection pool custom properties screen, click New to add a new custom property.

5.       Enter an arbitrary Name for the resource and as Value the JNDI name of your mirror failover Data Source as shown by the following picture:

what is websphere websphere tutorials websphere books websphere datasource

Click Apply and Save your data to the master configuration and repeat the above steps also on your mirrored failover data source to enable failback to the primary data source. Finally, restart the affected application servers.

Posted on

Create a Datasource with Websphere

what is websphere websphere tutorials websphere books

This chapter describes how to configure a database connection and the Java EE data source resource using the WAS Administration Console. As you will see in a minute, the configuration of a data source with WAS is not performed in a single step but is broken down into several parts, each one concerned with a particular aspect (JDBC Provider, Database connectivity, Security). Although this might appear quite a lot of work to do, it allows for extreme flexibility if you need to create or modify several data sources which are maybe different just for one aspect.

Continue reading Create a Datasource with Websphere

Posted on

Setting JVM Arguments for Websphere server

websphere application server network deployment websphere application server network deployment

Setting the JVM arguments of the Websphere servers can be done through the Administration Console by performing the following steps:

1.       Expand from the left Menu “Servers” and select the WAS Server from the list.

2.       From the “Server Infrastructure” list, expand the “Java and Process Management” option and click on Process Definition.

3.       In the Process Definition screen, select the “Java Virtual Machine”.

4.       Once in the Java Virtual Machine screen enter the appropriate settings for the server JVM as  shown by the following screen:

websphere application server network deployment websphere application server network deployment

Changes in the JVM settings will be active next time you will boot WAS.

Posted on

How to find out Websphere Administration ports

When you install several Websphere profiles on your Machine, each installation will use a port offset in order to avoid conflicts between the server instances. The reverse side of the coin is that you might forget or lose the Websphere administration port used in each Profile. That’s not a big issue; you can find out the correct administration port in two ways:

1. By inspecting the endpoint addresses are which stored in <WAS_ROOT>/config/cells/<your cell>/nodes/<node name>/serverindex.xml.

2. By opening the Profile installation log which is located in the <PROFILE_ROOT>/logs/AboutThisProfile.txt. This file contains all the ports used by your profile.