Monday, March 11, 2013

Creating JMS Adapter connection factory through WLST script in weblogic server

Creating JMS Adapter connection factory through WLST script in weblogic server:

The below WLST script will help us to create the JMS adapter connection factories. Before Executing the script change the details accordingly.

configureJMSAdapterConnection.py

TargetServerName='AdminServer'

soaHome='oracle/Middleware/Oracle_SOA1'

appPathJms=soaHome+'/soa/connectors/JmsAdapter.rar'
appNameJms='JmsAdapter'
moduleOverrideNameJms=appNameJms+'.rar'
JMSJNDIName = 'eis/wls/BAMQueueConnection'
JMSConnectionfactory='jms/BAMMonitoringConnectionfactory'
#Sever Details

moduleDescriptorName='META-INF/weblogic-ra.xml'
planPathJms=soaHome+'/soa/connectors/Plan_JMS.xml'

def createJMSConnectionFactory():

        edit()
        startEdit()
        startApplication(appNameJms)
        myPlanJms=loadApplication(appPathJms, planPathJms)
        makeDeploymentPlanVariable(myPlanJms,'ConnectionInstance_eis/Jms_JNDIName_13102979357209', JMSJNDIName , '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="oracle.tip.adapter.jms.IJmsConnectionFactory"]/connection-instance/[jndi-name="'+JMSJNDIName+'"]/jndi-name',moduleOverrideNameJms)
        makeDeploymentPlanVariable(myPlanJms, 'ConfigProperty_eis/JMS_JNDIName_ConnectionFactory_Name_13102979357210', JMSConnectionfactory,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="oracle.tip.adapter.jms.IJmsConnectionFactory"]/connection-instance/[jndi-name="'+JMSJNDIName+'"]/connection-properties/properties/property/[name="ConnectionFactoryLocation"]/value',moduleOverrideNameJms)

        myPlanJms.save();
        save();
        cd('/AppDeployments/JmsAdapter/Targets');
        updateApplication(appNameJms, planPathJms);
        activate(block='true');
     
  
def makeDeploymentPlanVariable(wlstPlan, name, value, xpath,overrideName, origin='planbased'):
    wlstPlan.destroyVariable(name)
    wlstPlan.destroyVariableAssignment(name, overrideName, moduleDescriptorName)
    variableAssignment = wlstPlan.createVariableAssignment(name, overrideName, moduleDescriptorName)
    variableAssignment.setXpath(xpath)
    variableAssignment.setOrigin(origin)
    wlstPlan.createVariable(name, value)
    print 'moduleDescriptorName=',moduleDescriptorName


def main():
       adminURL='t3://localhost:9001'
       adminUserName='weblogic'
       adminPassword='welcome1'
       connect(adminUserName, adminPassword, adminURL)
       createJMSConnectionFactory()
       disconnect()
main()

Login to the server, cd to the folder where the script is available and execute the script as shown below.

%MIDDLEWARE_HOME%\wlserver_10.3\common\bin\wlst.cmd configureJMSAdapterConnection.py


Monday, March 4, 2013

WLST script to configure JMS resources in weblogic server

WLST script to configure JMS resources in weblogic server

A JMS queue/Topic in Weblogic Server is associated with a number of additional resources:

JMS Server


A JMS server acts as a management container for resources within JMS modules. Some of its responsibilities include the maintenance of persistence and state of messages and subscribers. A JMS server is required in order to create a JMS module.

JMS Module


A JMS module is a definition which contains JMS resources such as queues and topics. A JMS module is required in order to create a JMS queue.

Subdeployment


JMS modules are targeted to one or more WLS instances or a cluster. Resources within a JMS module, such as queues and topics are also targeted to a JMS server or WLS server instances. A subdeployment is a grouping of targets. It is also known as advanced targeting.

Connection Factory


A connection factory is a resource that enables JMS clients to create connections to JMS destinations.

Persistent Store


It can be a UserDefined Persistent Store or a Default Persistent store. It is used for storing the Data (Messages).

JMS Queue/JMS Topic


JMS queue is a point-to-point destination type. A message is written to a specific queue or received from a specific queue.

JMS Topic follows Publish/Subscribe(Pub/Sub) model. Pub/sub messaging applications send and receive messages by subscribing to a topic

In this tutorial, we are going to configure JMS Queue with required additional resources through WLST script

WLST Script


The below script will help us to define the required JMS resources to enable the messaging queue

JMSConfiguration.properties
adminUserName=weblogic
adminUserPassword=weblogic1
adminServerHost=localhost
adminServerPort=7001
JMSConfiguration.py
from java.io import FileInputStream


Script

https://github.com/techforum-repo/youttubedata/tree/master/scripts/wlst/JMSConfiguration

Before executing the script, change the configurations as required.

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd JMSConfiguration.py



Now the required JMS resources are created and the queue is ready for messaging

The queue can be accessed using the below JNDI names

jms/BAMMonitoringConnectionfactory
jms/BAMMonitoringQueue







Wednesday, February 20, 2013

Migrating the BAM objects across environments with the ANT script – Oracle BAM 11g

Migrating the BAM objects across environments with the ANT script – Oracle BAM 11g

This post explains how to use the ANT script to migrate the Oracle BAM objects across the environments.The script can be run remotely from the client machine or from the server machine.
  • Create a folder BAMConfig and create two sub folders BAMObjects and config inside the BAMConfig folder
  • Copy the BAMICommandConfig.xml from $ORACLE_HOME/bam/config folder of the server to the config folder created in the above step.
  • Add the default user name and the password to the BAMICommandConfig.xml file
           <ICommand_Default_User_Name>weblogic</ICommand_Default_User_Name>
           <ICommand_Default_Password>hiyEbs0vwXPQrKh8yE7z3f7JVNhmLLEe+cR3bansiPc=</ICommand_Default_Password>

         Also verify the ADCServerPort - the BAM Server http listening port and   ADCServerName -  BAM Server host name properties.

Content of the configuration file:

<?xml version="1.0" encoding="UTF-8"?><BAMICommand>
<ADCServerPort>9001</ADCServerPort>
<ADCServerName>BAM Server hostname</ADCServerName>
<ICommand_Default_User_Name>weblogic</ICommand_Default_User_Name>
<ICommand_Default_Password>hiyEbs0vwXPQrKh8yE7z3f7JVNhmLLEe+cR3bansiPc=</ICommand_Default_Password>
<Communication_Protocol>t3</Communication_Protocol>
<SensorFactory>oracle.bam.common.statistics.noop.SensorFactoryImpl</SensorFactory>
<GenericSatelliteChannelName>invm:topic/oracle.bam.messaging.systemobjectnotification</GenericSatelliteChannelName>
</BAMICommand>

Default password should be encrypted else you will be receiving “ICommandEngine.MissingCredentials” error.

To encrypt the password configure the BAMICommandConfig.xml file in the $ORACLE_HOME/bam/config folder with the plain text password and run any standard icommand from the server (e.g $ORACLE_HOME/bam/bin/icommand -cmd export -type dataobject -name SampleDO -file C:\temp\SampleDO.xml) that will encrypt the password.
  • Create Export_BAM_Objects.xml file with the BAM export commands and place the same in BAMConfig folder created in the above step, the contents of the file look like below
<OracleBAMCommands>
   <!--import dataobjects-->
    <Export name="/Albin/BAMWebservice" type="dataobject" file="$BAM_PROJ_HOME$/BAMWebservice.xml"/>
    <Export name="/SampleDO" type="dataobject" file="$BAM_PROJ_HOME$/SampleDO.xml"/>
</OracleBAMCommands>
Configure the required export commands (exporting different type of objects) into this file.
  • Create Import_BAM_Objects.xml file with the BAM import commands and place the same in BAMConfig folder created in the above step, the contents of the file look like below
<OracleBAMCommands>
   <!--import dataobjects-->
   <Import file="$BAM_PROJ_HOME$/BAMWebservice.xml"/>
</OracleBAMCommands>
Configure the required import commands into this file.
  • Create the BAMBuild.xml file with the following contents and place the same in the BAMConfig folder created in the above step.
<project name="BAMMigrationProject" basedir="." default="config">
   <!--import the property file-->
   <property environment="env"/>
   <property name="src.dir" value="."/>
   <property name="proj.home" value="${env.BAM_PROJ_HOME}"/>
   <property name="oracle.home" value="${env.ORACLE_HOME}"/>
   <property name="oracle.common.home" value="${env.ORACLE_COMMON_HOME}"/>
   <property name="bam.core.lib.dir" value="${env.ORACLE_HOME}/bam/modules/oracle.bam_11.1.1"/>
   <property name="bam.tp.lib.dir" value="${env.ORACLE_HOME}/bam/modules/oracle.bam.thirdparty_11.1.1"/>
   <property name="dms.lib.dir" value="${env.ORACLE_COMMON_HOME}/modules/oracle.dms_11.1.1"/>
   <!--BAM Classpath required by icommand application-->
   <path id="bamClasspath">
      <fileset file="${bam.core.lib.dir}/oracle-bam-icommand.jar"/>
      <fileset file="${bam.core.lib.dir}/oracle-bam-common.jar"/>
      <fileset file="${bam.core.lib.dir}/oracle-bam-adc-ejb.jar"/>
      <fileset file="${dms.lib.dir}/dms.jar"/>
      <fileset file="${bam.tp.lib.dir}/jgroups-core.jar"/>
      <fileset file="${bam.tp.lib.dir}/xstream-1.3.1.jar"/>
      <fileset file="${bam.tp.lib.dir}/commons-codec-1.3.jar"/>
      <fileset file="${oracle.home}/../wlserver_10.3/server/lib/weblogic.jar"/>
      <fileset file="${oracle.common.home}/modules/org.jaxen_1.1.1.jar"/>
   </path>
   <!--export BAM DOs through icommand-->
   <target name="export" description="Export BAM dataobjects and reports" depends="config">
    <delete dir="${basedir}/BAMObjects" includeemptydirs="true" includes="*/**"></delete>
      <java classname="oracle.bam.icommand.Application" fork="true" dir="${src.dir}" classpathref="bamClasspath">
         <sysproperty key="oracle.bam.debug" value="true"/>
         <arg value="-CmdFile"/>
         <arg value="${basedir}/Export_BAM_Objects.xml"/>
      </java>
   </target>
   <!--import BAM DOs through icommand-->
   <target name="import" description="Import BAM dataobjects and reports" depends="config">
      <java classname="oracle.bam.icommand.Application" fork="true" dir="${src.dir}" classpathref="bamClasspath">
         <sysproperty key="oracle.bam.debug" value="true"/>
         <arg value="-CmdFile"/>
         <arg value="${basedir}/Import_BAM_Objects.xml"/>
      </java>
   </target>
   <!--Modify bam icommand files-->
   <target name="config">
       <!--replace $project.home$ with the actual project directory inside the command file-->
      <replace file="Export_BAM_Objects.xml" token="$BAM_PROJ_HOME$" value="${basedir}/BAMObjects"/>
      <replace file="Import_BAM_Objects.xml" token="$BAM_PROJ_HOME$" value="${basedir}/BAMObjects"/>
   </target>
</project>
  • To run the scripts from the server copy the BAMConfig folder with all the contents to the server.Set the environment variables ORACLE_HOME and ORACLE_COMMON_HOME(e.gORACLE_HOME=/oracle/Middleware/Oracle_SOA1;export ORACLE_HOME;ORACLE_COMMON_HOME=oracle/Middleware/oracle_common;export ORACLE_COMMON_HOME) and also set the PATH to ANT(e.g export PATH=$PATH:$ORACLE_HOME/../modules/org.apache.ant_1.7.1/bin)
         Execute the ant scripts
          ant –f BAMBuild.xml export

        The objects will be exported based on the commands in the Export_BAM_Objects.xml as an xml file   to the BAMObjects folder

         ant –f BAMBuild.xml import

           The xml file contents will be imported to BAM based on the commands in the Import_BAM_Objects.xml
  • To run the script from the client machine the JDeveloper with the same version as the BAM server should be installed.Set the ORACLE_HOME (e.g C:\EnvSetup\MiddlewareBlog\jdeveloper) and ORACLE_COMMON_HOME(e.g C:\EnvSetup\MiddlewareBlog\oracle_common) environment variables and also set the PATH to ANT
        Copy the commons-codec-1.3.jar file from the server location   ${env.ORACLE_HOME}/bam/modules/oracle.bam.thirdparty_11.1.1 to the <JDEV_HOME>\ jdeveloper\bam\modules\oracle.bam.thirdparty_11.1.1

Run the ant script


Wednesday, February 13, 2013

Different integration approaches to send the event data to Oracle BAM 11g

Different integration approaches to send the event data to Oracle BAM 11g

Oracle BAM provides a framework for Creating dashboards that display real-time data based on the events.
There are multiple approaches to send the event data to Oracle BAM.This document explains some of the approaches to send the data toOracle BAM.

Different approaches to send event data to BAM


Wednesday, January 30, 2013

JAX-WS webservice client basic authentication

JAX-WS webservice client basic authentication:


Sometimes we may need to create a webservice client for a JAX-WS webservice that require the basic authentication.
This post will explain the how to pass the username/password when invoking the basic authentication enabled web services from the client.

Java client with basic authentication details:

import java.util.*;
import javax.xml.ws.*;
import weblogic.wsee.security.unt.ClientUNTCredentialProvider;
import weblogic.xml.crypto.wss.WSSecurityContext;
import weblogic.xml.crypto.wss.provider.CredentialProvider;

public class DataObjectOperationsByNameClient
{
  @WebServiceRef
  private static DataObjectOperationsByName_Service dataObjectOperationsByName_Service;
  public static void main(String [] args)
  {
    dataObjectOperationsByName_Service = new DataObjectOperationsByName_Service();
    DataObjectOperationsByName dataObjectOperationsByName = dataObjectOperationsByName_Service.getDataObjectOperationsByName();
    String input="<DataObject Name=\"BAMWebservice\" Path=\"/Albin\">\n" + "<Contents>\n" + "<Row>\n" + "<Column Name=\"Field1\" Value=\"Albin\" />\n" +
    "<Column Name=\"Field2\" Value=\"I.T\" />\n" +"<column Name=\"Field3\" Value=\"TR\" />\n" +"</Row>\n" + "</Contents>\n" + "</DataObject>\n";   
      String USERNAME = "weblogic";
      String PASSWORD = "welcome1";
        try {
            BindingProvider bindingProvider = (BindingProvider) dataObjectOperationsByName;
            Map<String,Object> rc = (Map<String,Object>)bindingProvider.getRequestContext();
            List<CredentialProvider> credProviders = new ArrayList<CredentialProvider>();
            credProviders.add(new ClientUNTCredentialProvider(
USERNAME .getBytes(),PASSWORD .getBytes()));
            rc.put(WSSecurityContext.CREDENTIAL_PROVIDER_LIST, credProviders);
            rc.put(BindingProvider.USERNAME_PROPERTY, USERNAME);
            rc.put(BindingProvider.PASSWORD_PROPERTY, PASSWORD);;

            dataObjectOperationsByName.insert(input);
        } catch (BAMWebServiceException e) { e.printStackTrace();      }
  }
}