Saturday, 2 March 2013

Understanding Weblogic JMS ( Java Message Service )


Understanding Weblogic JMS ( Java Message Service ) 

I would be going to cover below as well as many more topics in my this post 

Weblogic JMS Basic
Weblogic JMS Clustering and High Availability
Weblogic JMS Queue, Topic, Connection Factory, Distributed Queue, Distributed Topic
Weblogic JMS Modules, Submodules
Weblogic JMS server

Basic Concepts


What is JMS and it's relation with weblogic


An enterprise messaging system enables applications to communicate with one another through the exchange of messages

A message is a request, report, and/or event that contains information needed to coordinate communication between different applications 

WebLogic JMS is an enterprise-class messaging system that is tightly integrated into the WebLogic Server platform
The Java Message Service (JMS) is a standard API for accessing enterprise messaging systems. Specifically, JMS:
1.  Enables Java applications sharing a messaging system to exchange messages
2.  Simplifies application development by providing a standard interface for creating, sending, and receiving messages


Basic Flow











So, from above picture, it's clear WebLogic JMS accepts messages from producer applications and delivers them to consumer applications.



Basic JMS components are

  1. JMS Server
  2. JMS Modules
  3. JMS Modules Subdeployments
  4. Connection Factory
  5. Queue, Topic
  6. Distributed Queue, Distributed Topic
  7. Persistent Store


JMS Server

JMS servers are environment-related configuration entities that act as management containers for JMS queue and topic resources within JMS modules that are specifically targeted to JMS servers. A JMS server’s primary responsibility for its targeted destinations is to maintain information on what persistent store is used for any persistent messages that arrive on the destinations, and to maintain the states of durable subscribers created on the destinations. 

You can assign/target a JMS server to one and only one Weblogic server

JMS Modules

It’s a group of  configuration resources like queues, topics, and connections factories, distributed queue, distributed topic etc.

You can target JMS module to either individual Weblogic server or to a cluster

JMS Subdeployments

You can define it under a JMS module, it’s a group of JMS resources like queue, topic, connection factory etc which you can deployed on individual or clustered managed servers.

Persistent Store

See my this post

Below JMS resources are defined under a particular subdeployments (under a particular JMS Module)

Connection Factory

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 like Weblogic JMS.

A connection factory supports concurrent use, enabling multiple threads to access the object simultaneously. You can use the preconfigured default connection factories provided by WebLogic JMS, or you can configure one or more connection factories to create connections with predefined attributes that suit your application.
Default connection factories, which you can look up using the following JNDI names:
§  weblogic.jms.ConnectionFactory
§  weblogic.jms.XAConnectionFactory
You only need to create a user-defined a connection factory if the settings of the default factories are not suitable for your application. 

It can be targeted to a server(s), cluster, JMS server (s)

By default it select the same target ( server(s), cluster ) as you defined for the JMS module under which you are defining this connection factories and this option disabled by default, means you cannot change target here.
To target it to a server(s), cluster or JMS server(s) by choice, during creation of the connection factory, select “advance targeting” option, Create a subdeployments, and select the targets where you want to deploy this connection factory

Recommended target is the same default one which is selected for parent JMS module

Queue

A single queue can be assigned to one and only one JMS server

To assign a queue to a JMS server, either first creates subdeployments with your targeted JMS server, and during creation of queue select  this  subdeployments, OR during creation of a queue, you have choice to create subdeployments.

Topic

A single topic can be assigned to one and only one JMS server

To assign a topic to a JMS server, either first creates subdeployments with your targeted JMS server, and during creation of topic select this subdeployments, OR during creation of a topic, you have choice to create subdeployments


Distributed Destinations
Distributed queue and Distributed Topic


A distributed queue represents a group of physical queues. If a QueueSender is created using the JNDI name of a distributed queue, any message sent from that QueueSender is delivered to only one physical queue destination. A decision is made every time a message is sent determining which member will get the message. This decision is based on a load-balancing algorithm provided by WebLogic. The default load-balancing scheme is a Round Robin, but you can use a Random load-balancing scheme to distribute messages to destination members at random.
When a QueueReceiver is created using a distributed queue name, it will connect to a physical queue member and, unlike a QueueSender, remain pinned to that destination until the QueueReceiver loses connection.

A distributed topic represents a group of physical topics. JMS client applications can create topic message producers and consumers using a distributed topic name. Your application doesn't know how many physical destination members the distributed topic has, which eliminates any special programming considerations when using this kind of clustered JMS resource.
When the TopicPublisher created with a distributed topic name publishes a message, the message is automatically sent to all members of the distributed topic so all subscribers get the message. Messages are forwarded to all topic member destinations even if a TopicPublisher is created using the JNDI name of a physical topic destination and not the distributed topic JNDI name.

Like connection factory, Distributed queue or topic can be targeted to server(s), cluster, JMS server(s)

By default it select the same target ( server(s), cluster ) as you defined for the JMS module under which you are defining this distributed queue or topic and this option disabled by default, means you cannot change target here.
To target it to a server(s), cluster or JMS server(s) by choice, during creation of the distributed queue or topic, select “advance targeting” option, Create a subdeployments, and select the targets where you want to deploy this distributed queue or topic

Recommended target is the cluster or same default one which is selected for parent JMS module

Note: - you can’t target a distributed queue or topic across different clusters.



Basic architecture is as below







Friday, 1 March 2013

Weblogic : How Oracle Web Cache works?


How Oracle Web Cache works?

For overview on web cache read my this post - http://weblogicserveradministration.blogspot.com/2012/12/oracle-web-cache-for-weblogic-server.html

Note: 

Oracle Web Cache 11g is packaging with Oracle Web Tier product. It is no longer part of the Application Server product. Oracle Web Cache 11g is based on Oracle WebLogic domain structure and it works with both Oracle Application Server and WebLogic Server.



















Below are the steps shows how your browser interact with the Oracle Web Cache

A browser sends a request to a Web site named www.company.com:80, This request in turn generates a request to Domain Name System (DNS) for the IP address of the Web site

NDS returns the IP address of the load balancer for the site that is 144.25.190.240

The browser sends the request for the Web page to the load balancer. In turn, the load balancer sends the request to Oracle Web Cache server 144.25.190.241.

If the requested content is in its cache, then Oracle Web Cache sends the content directly to the browser. This is called a cache hit.

If Oracle Web Cache does not have the requested content or the content is stale or invalid, it hands the request off to application Web server 144. 25.190.242. This is called a cache miss.

The application Web server sends the content to Oracle Web Cache.

Oracle Web Cache sends the content to the client and stores a copy of the page in cache. A page stored in the cache is removed when it becomes invalid or outdated. The invalidation period can be configured using the Web Cache Administration Manager.



Features of Oracle Web Cache 11G

Request filtering: 

You can configure Oracle Web Cache with request filters to take actions on incoming requests based on certain attributes of the request. An incoming request must pass through configured request filters for a given site before Oracle Web Cache processes it. By configuring request filters, you can prevent malicious code from exploiting software vulnerabilities.

MIME Type Match Criteria for Caching Rules: 

In addition to specifying the criteria for matching a caching rule to incoming requests based on the URL expression, you can base the match evaluation on the value of the content-type response header of objects. This feature simplifies the definition of caching rules, reduces the overall number of caching rules, and improves Oracle Web Cache performance.

Invalidation using response headers: 

You can enable an origin server to invalidate cached content through an HTTP response header.

Request-based logging: 

Oracle Web Cache stores every request internally and then writes them in bulk after the request to the event logs.

Oracle Diagnostic Logging (ODL) format for event logs: 

Oracle Web Cache supports the ODL format, which provides a common format for all diagnostic messages and log files.

Audit logging: 

Oracle Web Cache supports the Common Audit Framework for providing a uniform system for administering audits across Oracle Fusion Middleware components. The audit log files generated by Oracle Web Cache processes provide important information that can help to identify and diagnose potential security performance and configuration issues.

Secure caching: 

You can configure Oracle Web Cache to support caching content that is secured by Oracle Single Sign-On authentication with no other authorization requirements.




Required Software's

Oracle Weblogic Server
Oracle Application Development Runtime  ( This will give you EM console application )
Oracle OHS 

Note : - 

Oracle Web Cache can be monitored using the Oracle Enterprise Manager console or standalone Web Cache Administration console. A typical WebLogic Server installation does not included the Enterprise Manager. In order to add the Oracle Enterprise Manager feature to your existing WebLogic Server, you can install the Oracle Application Development Runtime product.



Oracle offers two tools for managing Oracle Web Cache:

Oracle Enterprise Manager Fusion Middleware Control
Oracle Web Cache Manager


Installation and Configuration Procedure

1. Install Weblogic Server

2. Install Application Development Runtime

     Select the same Middleware Home you have selected during weblogic installation
     If you haven't created domain  prior to ADR installation then go to next step, otherwise run your config.sh    
     again, select option extend the existing domain, select your existing domain, during application selection   
     select enterprises manager option, once extended, access your em console like http://host:port/em

3. Install Web cache component ( you have to run Oracle OHS installer for this )
    
   During installation on configure components page, select all three options, "oracle HTTP server" ( optional    
   - if you want to use it ),"Oracle Web cache", "Associated selected components with weblogic domain" ( if 
    you want to monitor and administration it via EM console ), 
   



Further details I will post soon...if you need it urgently write me on mnbloghelpdesk@gmail.com







Reference :  www.oracle.com

Wednesday, 27 February 2013

Weblogic Server - Coherence Configuration Example


Weblogic Server - Coherence Configuration

For theoretical knowledge on coherence read my this post - http://weblogicserveradministration.blogspot.com/2011/05/oracle-coherence-37-coherenceweb.html

In this post I am going to cover practical example on Coherence

I have used Weblogic Server 10.3.5 + Coherence 3.6

High Level Steps

1.  Install weblogic server 10.3.5 with coherence 3.6 or 3.7
2.  Create a domain
3.  Create a machine, start node manager and check status from console if it's accessible
4.  Create a a simple cluster with two managed servers, and assign both managed servers to 
      machine
5.  Create a Coherence cluster and assign your above defined cluster to coherence cluster
      [ OR instead of above step2 and step3, you can just create two managed servers, then  
         create a coherence cluster and assign both managed servers to this coherence cluster ]
6.  Start a cache server
7.  Start both managed servers
8.  Deploy shared library files
9.  Create a testing application and deploy on cluster
10.Test 

Steps

1. For installation see my other post 
http://weblogicserveradministration.blogspot.com/2010/11/installation-ii-console-mode.html

2. For domain creation see my other post
http://weblogicserveradministration.blogspot.com/2012/12/weblogic-domain-creation-create.html
http://weblogicserveradministration.blogspot.com/2010/11/domain-creation-console-mode-dev.html
http://weblogicserveradministration.blogspot.com/2010/10/create-domain.html

3. For machine,node manager configuration see my other post
http://weblogicserveradministration.blogspot.com/2010/10/configure-start-stop-node-manager.html

4. To create a simple cluster and assign servers to cluster see my other post
http://weblogicserveradministration.blogspot.com/2010/10/vertical-clustering-step-by-step.html

5. Create a coherence cluster and assign your above created cluster to this coherence cluster

a. Login to admin console
b. Click on Coherence Clusters option on left hand side panel
c. Do the configuration like below and save

Unicast Listen Address - your machine hostname or i.p
Unicast Listen Post - 8085 ( or any other available port of your machine )
Multicat Listen Address - 231.1.1.1 ( or any multicast range available i.p but make sure this need to update in coherence server startup script which i will explain later )
Multicast Listen Port - 7777 ( or you can use any other available port of your machine but make sure this need to update in coherence server startup script which i will explain later )
























   











After creating coherence cluster, click on Target tab and assign your previously create simple cluster to this coherence cluster


































Now you can see like below under coherence cluster option










6. Start Cohrence Server

Copy the below contents, paste in a text file and rename it as .bat ( on windows )
( if you are on unix based systems then change scripts variable settings, path etc accordingly )

Start-Coherence.bat

setlocal

set COHERENCE_HOME=C:\Oracle\Middleware2\coherence_3.6
set COH_OPTS=%COH_OPTS% -server -cp %COHERENCE_HOME%\lib\coherence.jar;%COHERENCE_HOME%\lib\coherence-web-spi.war;
set COH_OPTS=%COH_OPTS% -Dtangosol.coherence.management.remote=true -Dtangosol.coherence.cacheconfig=/WEB-INF/classes/session-cache-config.xml -Dtangosol.coherence.distributed.localstorage=true -Dtangosol.coherence.clusterport=7777 -Dtangosol.coherence.clusteraddress=231.1.1.1 -Dtangosol.coherence.session.localstorage=true
java %COH_OPTS% -Xms256m -Xmx256m -XX:MaxPermSize=256m com.tangosol.net.DefaultCacheServer
:exit

Now start above create script

Output should be like below

























7. Start both managed servers from console

8.  Deploy below shared libraries on your cluster ( During deployment make sure to choose 
     option deploy this file as library not application for both files )

 coherence-web-spi.war from  ORACLE_HOME\coherence_3.6\lib and  active-cache-1.0.jar  
  from  ORACLE_HOME\wlserver_10.3\common\deployable-libraries

9.  Create a testing application like below

[1] Create a folder CoherenceTest
[2] Inside CoherenceTest folder create 
      a. META-INF folder, Inside it a file with name manifest.mf with below contents


Extension-List: active-cache
active-cache-Extension-Name: active-cache
active-cache-Specification-Version: 1.0
active-cache-Implementation-Version: 1.0


 [3] WEB-INF folder
        
        3.1 inside it, create a file web.xml with below contents

               <?xml version = '1.0' encoding = 'windows-1252'?>
               <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web- 
               app_2_4.xsd" 
               xmlns="http://java.sun.com/xml/ns/j2ee" version="2.5">
              <description>Empty web.xml file for Web Application</description>       
             </web-app>
       
         3.2 inside it, create a file weblogic.xml with below contents

         <weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"  
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
         xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app 
         http://www.oracle.com/technology/weblogic/weblogic-web-app/1.1/weblogic-web-app.xsd">
         <library-ref>
           <library-name>coherence-web-spi</library-name>
         </library-ref>
         <coherence-cluster-ref>
            <coherence-cluster-name>CoherenceCluster</coherence-cluster-name>
         </coherence-cluster-ref> 
           </weblogic-web-app>

( Make sure here cluster name exactly the same you have given to your coherence cluster )

        3.3 inside it, create a folder with name lib and copy coherence.jar file from 
               COHERENCE_HOME\lib to here ( ORACLE_HOME\coherence_3.6\lib in my case )
        
 [4]. A jsp file with name counter.jsp ( copy and paste below code inside it )


<html>
    <body>
<h3>
      Counter :
      <%
         Integer counter = new Integer(1);
         HttpSession httpsession = request.getSession(true);
         if (httpsession.isNew()) {
                httpsession.setAttribute("count", counter);
                out.println(counter);
         } else {
                int count = ((Integer) httpsession.getAttribute("count")).intValue();
                httpsession.setAttribute("count", new Integer(++count));
                out.println(count);
         }
      %>
      </h3>

    </body>
</html>


Below is the structure




















10. Deploy this CoherenceTest application as in exploded form on your cluster

11. Test

Now, first access you application using first managed server URL

http://host:first_managed_server_port/CoherenceTest/counter.jsp

it will show you as counter : 1














After that access your application using second managed server URL

http://host:second_managed_server_port/CoherenceTest/counter.jsp

it will show you counter : 2












So, here session shared on your external coherence server and shared across servers on your cluster..

you are done...cheers!!!!!!!


Feel free to write me in case you have any issues or doubt....



Saturday, 23 February 2013

Weblogic Server Deployment


Weblogic Server Deployment

Deploy war file


Access admin console

http://admin_host:admin_port/console


Click on Lock & Edit button ( If have production mode domain )



















Click on "Deployment" option on your left hand side panel


























Click on "install" option on right hand side, and next

Browse you application and select next


Select option install this deployment as an application and select next


Select your target server or cluster and click next



Select all default options ( or select according to your need like change application name with more significant text, deployment modes etc )



Select finish option



Click on activate changes ( if your domain in production mode )



Click on deployment, check your application box, click on start > servicing all requests



your application will come in active state ( of course if there is no issues with your application :) )



now go ahead and access your application

In my case, below is the screen




Other Posts

Application Status
Packaging Files
Disable on demand deployment option
Deployment Forms - Archive & Exploded
Side by Side Deployment
Quick Deployment Using WLST
Make You Application as Default Application
Deployment As Library Option
Creating WAR File
Web Application ( WAR ) Basic Concepts
EAR File Directory Structure
Autodeployment
Partial Deployment Of Static Files





















Friday, 14 December 2012

Weblogic List the admin accounts

Weblogic Server : List the admin accounts

1. create a .py file, suppose admindisplay.py and copy below contents


import os
import sys
username='weblogic'
password='weblogic123'
url='t3://localhost:40510'
domain='JJTU_Domain1'
groupName='Administrators'
connect(username, password, url)
cd('SecurityConfiguration/'+domain+'/DefaultRealm/myrealm/AuthenticationProviders/DefaultAuthenticator')
ListUsersInGroups=cmo.listAllUsersInGroup(groupName,'*',0)
print ListUsersInGroups

Note - Change username, password, host, port and domain name accordingly

2. go to your_domain/bin and run setDomainEnv script

3. execute the admindisplay.py script like below ( see command in red )

--------------------------------------------------------------------------

C:\Oracle\Middleware2\user_projects\domains\JJTU_Domain1\bin>java weblogic.WLST admin.py

( Output )

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://localhost:40510 with userid weblogic ...
Successfully connected to Admin Server 'JJTU_AdminServer' that belongs to domain 'JJTU_Domain1'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

array(java.lang.String,['weblogic', 'administrator'])

--------------------------------------------------------------------------------

Weblogic Server ear file directory structure


Weblogic Server : Directory Structure Of  ear ( Enterprise Applications ) File


In weblogic, Archived file with extension .ear also called enterprises application is a group of other java enterprises modules such as web applications ( .war archive ), EJB's ( .jar archive ) etc. it has it's own descriptor file called application.xml which contains information about the different kind of modules packaged or available inside that particular .ear file or you can say, it's a standard J2EE configuration file that specifies which modules are in the J2EE application. 

Apart from application.xml, one more weblogic descriptor file is there for ear file called weblogic-application.xml but optional if you are not using any WebLogic Server extensions. weblogic-application.xml file is the WebLogic Server-specific deployment descriptor extension for the application.xml Java EE deployment descriptor and this is where you configure features such as shared Java EE libraries referenced in the application and EJB caching.

Both weblogic-application.xml & application.xml located in the META-INF


So, an EAR file contains - 

1. META-INF ( containing application.xml,weblogic-application.xml & MANIFEST.MF )
2. APP-INF  ( containing folder "lib" and "classes", explained later )
3. Web Module ( war archive file )
4. EJB Module ( jar archive file )


See the diagram below 







1. META-INF ( containing application.xml,weblogic-application.xml & MANIFEST.MF )

The META-INF/ directory can contain the following files :

application.xml, as I have explained above, contains information about the different kind of modules packaged or available inside that particular .ear file or you can say, it's a standard J2EE configuration file that specifies which modules are in the J2EE application. 

 weblogic-application.xml file is the WebLogic Server-specific deployment descriptor extension for the application.xml Java EE deployment descriptor and this is where you configure features such as shared Java EE libraries referenced in the application and EJB caching. it's an optional file if you are not using any WebLogic Server extensions.

MANIFEST.MF is also an optional file that can be used to specify additional meta-information for the EAR.
( for more details visit http://docs.oracle.com/javase/1.4.2/docs/guide/jar/jar.html#JAR )

2. APP-INF  ( containing folder "lib" and "classes", explained later )

APP-INF folder is used to place the common modules used between all of your application archived in a particular ear file. For example, suppose you have archived two war files like myapp1.war and myapp2.war in a ear file called myentapp.ear, and there are few functionality common on both web archive file so instead of creating and archiving separate ejb's for both web app, you can archive common ejb's in a jar file like shared.jar and place that file inside APP-INF/lib folder.

 In the same way, if you have some common class files for both war files then you can place then inside APP-INF/classes.


3. Web Module ( war archive file )

See my this post - http://weblogicserveradministration.blogspot.com/2010/10/deployment-creating-war-file-and.html


4. EJB Module ( jar archive file )

EJB deployment descriptors are defined in ejb-jar,xml.
Weblogic related descriptors are defined in weblogic-ejb-jar.xml.
Further, class files are located under main jar folder.


How to create a EAR file 


To create an ear ( Enterprises Application ) - 

1. Create a temporary staging directory anywhere on your hard drive.

2. Copy the Web archives (WAR files) and EJB archives (JAR files) into the staging directory.

3. Create a META-INF subdirectory in the staging directory

4. Set up your shell environment by running setDomainEnv script inside domain/bin folder

5. Create the application.xml deployment descriptor file that describes the enterprise   
     application in the META-INF directory. 

6. Optionally create the weblogic-application.xml file manually in the META-INF directory if 
    needed.

7. Create the Enterprise Archive (EAR file) for the application, using a jar command such as:

     jar cvf application.ear -C your_staging_dir



Other My Related Posts


1. WAR File Directory Structure, Creating war file
2. WAR Files Overview
3. Packaging Weblogic Deployment Files
4. Create jar, war and ear Files
5. Difference Between jar, war and ear Files