Tuesday, February 28, 2012

Tortoise SVN and Eclipse SVN plugin conflicts

Although not scientifically proven, it seems that committing stuff in SVN with Tortoise SVN while you check it out in Eclipse SVN Plugin can create trouble.

For this reason, avoid using both products on the same project.

A Java cache for OSB

http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html

ConcurrentHashMap is a Thread-safe implementation of a HashMap, optimized for concurrent reads and writes scenario.

You can expose a ConcurrentHashMap as a Static attribute of a Java Bean, accessed by OSB Message Flow via Java Callout or Custom XPath.

cache (the individual cache) is a HashMap - where String is the Object Key (e.g. the userId), and XmlObject is the corresponging cached response (e.g. the User object). A Cache will contain homogeneous objects (XmlObject of the same type).

caches (collection of cache) is a HashMap, where String is the Cache Name (e.g. "USERS")


caches.get("USERS").get("1234") will return the XmlObject describing user 1234


caches.clear() will remove all caches
caches.get("USERS").clear() will clear an individual cache

Caches can be cleared with a REST Proxy Service http://myhost:myport/CacheService/ClearCache/USERS
One can use a cron job with a wget command to clear them periodically

One can add metainformation to a Cache, such as the creation time, the last update time, the last access time...

One can expose management of the Caches via JMX (registering the MBeanAgent into the Weblogic or JVM MBean tree), and administering via JConsole or any other JMX-Enabled tool.

The advantage of storing an XmlObject in cache is that it doesn't require conversion inside OSB, since OSB stores complex variables in XmlObject format.
In Coherence the object would be stored in POF format - requiring further materialization to XmlObject format


Monday, February 27, 2012

VETRO Pattern

VETRO is a mouth-filling term for:
- Validate
- Enrich
- Transform
- Route
- Operate

http://soa.sys-con.com/node/46170

"Operate" is mysterious.... someone believes it should be "Orchestrate"... I understand that "Operate" means "Invoke a remote Endpoint".

Anyway, as usual, patterns often create a Procustes' Bed of abstract definitions draining away energies from a free independent analysis of reality.


(Theseus kills Procustes)

Sunday, February 26, 2012

SDEdit, sequence diagrams

trying to practice the SDEdit (my previous post here)

Unfortunately I understand stuff only "In Action" and "A step at a time", and I believe in documentation embedded in the code.
So here is my attempt to bring some light into the SDEdit notation.

http://sdedit.sourceforge.net/index.html


#the # is a comment
#the #! is a title
#![SD ticket order]

#this section declares Objects, with Syntax <name>:<type>[<flags>] "<label>"

#flag p means process, e means external
#flag x means auto-destruction
ext:External[pe]
user:Actor "JohnLennnon"
/order:Order[x] "MyOrder"
db:TicketDB
acc:Account

ext:=user.order a ticket!
user:order.new()
#<caller>[<s>]:<answer>=<callee>[m].<message>
order:return=db.reserve(date,count)
db:return=acc.debit(cost)
acc:return=db.bonus(date,count)




Thursday, February 23, 2012

Bully survival guide

You believed you were an adult?

No, you are not. You are just a super-sized kid, and just like when you were a kid playing in the street (we used to play in the street in the pre-electronics era), you are surrounded by other friendly kids and not-so-friendly kids - a.k.a. BULLIES.

Bully is someone who - instead of being sympathetic - darts stinging arrows of sarcasm at you when you are emotionally most exposed.

Bully is a kid who - more or less by brute force or cunning - grabs for himself the best tasks and leaves the boring work to others.



A Bully will occupy the best desk. Bully will most of the time NOT document his stuff (so as to keep more power on the project)... he will finish his stuff without testing it, and leave you the boring part of mending the broken details. He will even steal from you the best room in the hotel, etc.

Bully will ask you direct questions aimed at revealing your fragility and making you feel inferior. YOU DON´T NEED TO ANSWER. When asked cheeky question, just reply "why on earth do you want to know? This should not concern you." - this will make HIM look like the wrongdoer.

Most likely the Bully was exposed to a lot of violence when a child, so he introjects the rule that violence is OK.
Possibly he was also educated in a family with highly competitive and individualistic values.

Occasionally, the BULLY might simply be so self-centered that he does not even realize that he is being obnoxious - he assumes that he is the Center Of All Things and doesn't feel any empathy for other human beings, for the Planet and for other creatures.

The best time to study a Bully is when he meets new people. Typically the bully will ask the newcomer questions that allow him to boast about his knowledge and experience. Example "where are you from?" "Cambodia" "Oh I have seen this movie featuring a girl from Cambodia", "oh I can say hello and how-are-you in Cambodian". He will never say something warm and welcoming like "oh Cambodia is such a beautiful country and Cambodian such a charming language".

For the Bully, the world is a stage where to strut his super-inflated Ego.

Bully knows the world through movies, not through direct experience. He is too techie to actually venture out and get in real contact with reality.

Possibly, he is highly carnivore, technology freak and he adores to drive cars. He casts scorn on ecologists and doesn't give a damn about the future of this planet. Basically, he is a Homo Destructor (aka Homo Destroyens), the most common form of human being.



It's not easy to deal with the bully, unless you are a violent person yourself.

First, don't remain isolated, talk about Bully with your friends, they will help you overcome the trauma.

Second, ignore the bully and treat him coldly.

Third, refuse to clean up his mess, unless management explicitly asks you.

There is no point in talking to management, most likely they will believe you are grown up enough to cope with these issues on your own.
Unless there have been episodes involving physical violence, it's very difficult to prove that you are being subject to moral violence. Humans can see blood on your skin but not in your soul.

http://high-schools.com/blog/problems-facing-students/bullying-survival-tips/


PS one month after: Bully has left, and soon after we discovered the extremely poor quality of his work... so far nobody had realized, because bully was keeping it concealed. Management also realized that Bully was only promoting his own agenda, playing with technology rather than resolving business needs, with a typical "information hiding" strategy. Now we are all much more relieved and we are able to organize and discuss democratically.
Most of the stuff Bully has done, has been thrown away and redone. The rest keeps giving serious maintenance problems.

Tuesday, February 21, 2012

validateControlSocket

We are getting some weird socket timeout problems
on FTPClient and FtpDescriptor there is a JCA property
control.read.timeout
by default it's 15000
and also a
control.read.error_on_timeout
by default it's true

you can set it to false to get rid of the problem


RETR command: http://cr.yp.to/ftp/retr.html

A RETR request asks the server to send the contents of a file over the data connection already established by the client.


####<Feb 21, 2012 4:10:29 PM CET> <Debug> <AlsbJcaFrameworkAdapter> <hqchnesoa102> <osbdv2ms1> <[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <7f9b72b69446518a:-3e7d8906:1359f3f0c67:-8000-0000000000000a3b> <1329837029661> <BEA-000000> <FTP Command: RETR, reply:
150 Opening data connection for /acme/environments/env-0/ave/tmp/ITEM_X_ACME_AVE_1329837028553.xml (408 bytes).

>

####<Feb 21, 2012 4:10:29 PM CET> <Debug> <AlsbJcaFrameworkAdapter> <hqchnesoa102> <osbdv2ms1> <[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <7f9b72b69446518a:-3e7d8906:1359f3f0c67:-8000-0000000000000a3b> <1329837029661> <BEA-000000> <shortCircuit==>true>

####<Feb 21, 2012 4:10:29 PM CET> <Debug> <AlsbJcaFrameworkAdapter> <hqchnesoa102> <osbdv2ms1> <[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <7f9b72b69446518a:-3e7d8906:1359f3f0c67:-8000-0000000000000a3b> <1329837029661> <BEA-000000> <validateControlSocket::Control socket being read by [[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)']>

####<Feb 21, 2012 4:10:44 PM CET> <Debug> <AlsbJcaFrameworkAdapter> <hqchnesoa102> <osbdv2ms1> <[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <7f9b72b69446518a:-3e7d8906:1359f3f0c67:-8000-0000000000000a3b> <1329837044661> <BEA-000000> <Timed out in [15000] msecs>

####<Feb 21, 2012 4:10:44 PM CET> <Debug> <AlsbJcaFrameworkAdapter> <hqchnesoa102> <osbdv2ms1> <[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <7f9b72b69446518a:-3e7d8906:1359f3f0c67:-8000-0000000000000a3b> <1329837044662> <BEA-000000> <Exception caught while reading control socket
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at oracle.tip.adapter.ftp.FTPClient$BufferedTimedReader.readLine(FTPClient.java:2385)
at oracle.tip.adapter.ftp.FTPClient.validateControlSocket(FTPClient.java:931)
at oracle.tip.adapter.ftp.FTPClient.getBinaryFileAsStream(FTPClient.java:1225)
at oracle.tip.adapter.ftp.FTPAgent.getBinaryFileAsStream(FTPAgent.java:654)
at oracle.tip.adapter.ftp.FTPAgent.getContentAsStream(FTPAgent.java:700)
at oracle.tip.adapter.ftp.inbound.FTPSource.getContents(FTPSource.java:987)
at oracle.tip.adapter.ftp.inbound.FTPSource.getFileFromSource(FTPSource.java:912)
at oracle.tip.adapter.ftp.outbound.FTPIoOperation.ioOnly(FTPIoOperation.java:119)
at oracle.tip.adapter.ftp.outbound.FTPIoOperation$2.perform(FTPIoOperation.java:844)
at oracle.tip.adapter.ftp.outbound.FTPInteraction.executeFTPIo(FTPInteraction.java:287)
at oracle.tip.adapter.ftp.outbound.FTPInteraction.execute(FTPInteraction.java:245)
at oracle.tip.adapter.sa.impl.fw.wsif.jca.WSIFOperation_JCA.performOperation(WSIFOperation_JCA.java:529)
at oracle.tip.adapter.sa.impl.fw.wsif.jca.WSIFOperation_JCA.executeOperation(WSIFOperation_JCA.java:353)
at oracle.tip.adapter.sa.impl.fw.wsif.jca.WSIFOperation_JCA.executeRequestResponseOperation(WSIFOperation_JCA.java:312)
at oracle.tip.adapter.sa.impl.JCABindingReferenceImpl.invokeWsifProvider(JCABindingReferenceImpl.java:350)
at oracle.tip.adapter.sa.impl.JCABindingReferenceImpl.request(JCABindingReferenceImpl.java:253)
at com.bea.wli.sb.transports.jca.binding.JCATransportOutboundOperationBindingServiceImpl.invoke(JCATransportOutboundOperationBindingServiceImpl.java:150)
at com.bea.wli.sb.transports.jca.JCATransportEndpoint.sendRequestResponse(JCATransportEndpoint.java:209)
at com.bea.wli.sb.transports.jca.JCATransportEndpoint.send(JCATransportEndpoint.java:170)
at com.bea.wli.sb.transports.jca.JCATransportProvider.sendMessageAsync(JCATransportProvider.java:598)
at sun.reflect.GeneratedMethodAccessor1154.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.wli.sb.transports.Util$1.invoke(Util.java:83)
at $Proxy128.sendMessageAsync(Unknown Source)
at com.bea.wli.sb.transports.LoadBalanceFailoverListener.sendMessageAsync(LoadBalanceFailoverListener.java:148)
at com.bea.wli.sb.transports.LoadBalanceFailoverListener.sendMessageToServiceAsync(LoadBalanceFailoverListener.java:603)
at com.bea.wli.sb.transports.LoadBalanceFailoverListener.sendMessageToService(LoadBalanceFailoverListener.java:538)




still chasing what is at the origin of the problem...

Sunday, February 19, 2012

List JMS queues in WebLogic with WLST

see also my previous post using Java

connect('Pierluigi', 'weblogic1', 't3://localhost:7001')
easeSyntax()

allJMSResources = cmo.getJMSSystemResources()
for jmsResource in allJMSResources:
   module = jmsResource.getName()
   print "MODULE", module
   udqs = jmsResource.getJMSResource().getUniformDistributedQueues()
   for udq in udqs:
      print "QUEUE", udq.getName(), " JNDINAME", udq.getJNDIName()


or the simplified version (only JNDI Names)

allJMSResources = cmo.getJMSSystemResources()
for jmsResource in allJMSResources:
   module = jmsResource.getName()

   udqs = jmsResource.getJMSResource().getUniformDistributedQueues()
   for udq in udqs:
      print udq.getJNDIName()




or this other version (first print all modules, then all queues with also module info)


connect('Pierluigi', 'weblogic1', 't3://localhost:7001')
easeSyntax()

allJMSResources = cmo.getJMSSystemResources()
for jmsResource in allJMSResources:
   module = jmsResource.getName()
   print "MODULE=", module

for jmsResource in allJMSResources:
   module = jmsResource.getName()
   udqs = jmsResource.getJMSResource().getUniformDistributedQueues()
   for udq in udqs:
      print "MODULE=", module, "QUEUE", udq.getName(), " JNDINAME", udq.getJNDIName()




BEA-010096 unable to connect to the JMS destination

If your JMS proxy service is configured with a jms URI which doesn't match existing resources, you will get plenty of this in the logs:

The Message-Driven EJB: RequestEJB-8751392536757391289--69cc26eb.1359130af7a.-7e0e is unable to connect to the JMS destination or bind to JCA resource adapter: jms.jndi.dq.ACME.ACMEQueue. Connection failed after 3,791 attempts. The MDB will attempt to reconnect/rebind every 10 seconds. This log message will repeat every 600 seconds until the condition clears.


It is advisable to grep BEA-010096 on the logs

http://docs.oracle.com/cd/E13222_01/wls/docs91/messages/EJB.html

Saturday, February 18, 2012

find: paths must precede expression

the command
find .
recursively print all files starting from current directory

find . -name *.txt

should theoretically print only the .txt files.

It fails from the shell prompt with
"find: paths must precede expression"

this must be because the shell explodes *.txt before evaluating find.

Workaround: enclose '*.txt' in quotes

find . -name '*.txt'

vsftpd on Linux RedHat

homepage
https://security.appspot.com/vsftpd.html

download here
https://security.appspot.com/downloads/vsftpd-2.3.5.tar.gz

copied to Linux server
gunzip vsftpd-2.3.5.tar.gz
tar xvf vsftpd-2.3.5.tar
cd vsftpd-2.3.5

/lib/libcap.so.1: could not read symbols: File in wrong format

http://www.andreaswacker.com/blog/2009/01/23/sysdeputilc162-error-expected-declaration-specifiers-or-before-capset/

vi vsf_findlibs.sh


# Look for libcap (capabilities)
#if locate_library /lib/libcap.so.1; then
# echo "/lib/libcap.so.1";
if locate_library /lib/libcap.so.2; then
echo "/lib/libcap.so.2";
else
locate_library /usr/lib/libcap.so && echo "-lcap";
locate_library /lib/libcap.so && echo "-lcap";
locate_library /lib64/libcap.so && echo "-lcap";
fi


I still get

gcc -o vsftpd main.o utility.o prelogin.o ftpcmdio.o postlogin.o privsock.o tunables.o ftpdataio.o secbuf.o ls.o postprivparent.o logging.o str.o netstr.o sysstr.o strlist.o banner.o filestr.o parseconf.o secutil.o ascii.o oneprocess.o twoprocess.o privops.o standalone.o hash.o tcpwrap.o ipaddrparse.o access.o features.o readwrite.o opts.o ssl.o sslslave.o ptracesandbox.o ftppolicy.o sysutil.o sysdeputil.o -Wl,-s `./vsf_findlibs.sh`
/usr/bin/ld: cannot find -lcap
collect2: ld returned 1 exit status
make: *** [vsftpd] Error 1



Ok I give up for now....

WebLogic graceful shutdown command

I believe most of us shutdown WebLogic with a kill "pid" .

If the process doesn't want to die, we do a kill -9 "pid" and we mutter "die, bastard!"

This is not very elegant and ladylike.

The alternative is through the Web Console, you can control each instance inclusive the Admin.

Otherwise you can use:
java weblogic.Admin -url t3://localhost:7001/ -username weblogic -password weblogic FORCESHUTDOWN yourserver

or the $DOMAIN_HOME/stopWebLogic.sh which in turns uses a WLST script invoking the WLST shutdown command

Here
http://docs.oracle.com/cd/E15523_01/web.1111/e13708/overview.htm
the official documentation on how to startup and shutdown

Nice script to start WebLogic Admin Server

#!/bin/sh

#declare variables
DOMAIN_HOME=/opt/oracle/domains/mydomain
SERVER_NAME=myAdminServer

#verify if Domain Directory exists

if [ ! -d $DOMAIN_HOME ] ; then
echo Domain directory $DOMAIN_HOME does not exist!
exit 1
fi

#start admin in nohup, redirect stdout and stderro
nohup ${DOMAIN_HOME}/startWebLogic.sh > /var/log/weblogic/server/${SERVER_NAME}.out 2>&1 &

#make sure that AdminServer has actually started

servers=`jps -v | grep Server | grep $SERVER_NAME | wc -l`
if [ "servers" == "0" ] ; then
echo Server is not started
exit 1
fi

#show all running weblogic servers
jps | grep Server

Tuesday, February 14, 2012

Listing all JMSServer, JMSModules, JMSDestinations with JNDI names in WebLogic

Ever wanted to list jms queues in weblogic ?

Thanks to Chris Vugrinec http://datalinks.nl/wordpress/

package com.acme.jms;

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Hashtable;

import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import weblogic.j2ee.descriptor.wl.QueueBean;
import weblogic.management.configuration.DomainMBean;
import weblogic.management.configuration.JMSConnectionFactoryMBean;
import weblogic.management.configuration.JMSQueueMBean;
import weblogic.management.configuration.JMSServerMBean;
import weblogic.management.configuration.JMSSystemResourceMBean;
import weblogic.management.j2ee.SessionBeanMBean;
import weblogic.management.mbeans.custom.JMSSystemResource;
import weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean;
import weblogic.management.jmx.MBeanServerInvocationHandler;

public class ConnectionBeaImpl {
      
    protected final Log logger = LogFactory.getLog(getClass());
      
    
      private JMXConnector jmxConn = null;
      DomainMBean domainMBean = null;
      DomainRuntimeServiceMBean domainRuntimeServiceMBean = null;
      SessionBeanMBean sessionManagementMBean = null;
      
      
      public MBeanServerConnection openConnection(String hostname, int port, String username, String password) throws IOException,MalformedURLException {
            JMXServiceURL serviceURL = new JMXServiceURL("t3", hostname, port, "/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME);
            Hashtable h = new Hashtable();
            h.put(Context.SECURITY_PRINCIPAL, username);
            h.put(Context.SECURITY_CREDENTIALS, password);
            h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");
            //h.put("jmx.remote.x.request.waiting.timeout", new Long(60000));
            return JMXConnectorFactory.connect(serviceURL, h).getMBeanServerConnection();
      }     


      
      public void closeConnection() {
            try {
                  jmxConn.close();
            } catch (IOException ex) {
                  logger.error("Exception in closing connection: "+ex.getMessage());
            }finally{
                  try{
                        jmxConn.close();
                  } catch (IOException ex) {
                        logger.error("Exception in final stage of closing connection: "+ex.getMessage());
                  }           
            }
      }
      
      
      public static void main(String [] args){
            
            ConnectionBeaImpl x = new ConnectionBeaImpl();
            try {
                  MBeanServerConnection bco = x.openConnection("acme.com", 7001, "weblogic", "weblogic1");

                  DomainRuntimeServiceMBean domainRuntimeServiceMBean = (DomainRuntimeServiceMBean) MBeanServerInvocationHandler.newProxyInstance(bco, new ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME));        
                  DomainMBean dem = domainRuntimeServiceMBean.getDomainConfiguration();
                  JMSSystemResourceMBean[] jmsSRs = dem.getJMSSystemResources();
                  
                  JMSServerMBean[] jmsSvrs = dem.getJMSServers();
                  for(JMSServerMBean jmsSvr : jmsSvrs){
                        System.out.println("JMS Servername: "+jmsSvr.getName());
                        
                  }
                  
                  
                  for(JMSSystemResourceMBean jmsSR : jmsSRs){
                        System.err.println(jmsSR.getName());
                        QueueBean[] qbeans = jmsSR.getJMSResource().getQueues();
                        
                        for(QueueBean qbean : qbeans){
                             System.out.println("JNDI NAME: "+qbean.getJNDIName()+" queuename : "+qbean.getName());
                        }
                  }
                  //ServerRuntimeMBean serverRtBean = domainConfigX.createServerRuntimeMBean(domain.getAdminserver());

                  
                  //Domain domain = domainFactoryX.getDomain(domainName);
                  
                  
            } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
      }

}






Friday, February 10, 2012

weblogic edit.lok

cd $DOMAIN_HOME
(nobody has acquired the lock to edit the domain configuration)

ls -ltr

-rw-r----- 1 soa soa 32 Feb 10 12:58 edit.lok

cat edit.lok
#
#Fri Feb 10 12:58:15 CET 2012


This should be the last time someone released the lock


Now I acquire the lock on the console:

ls -ltr

-rw-r----- 1 soa soa 138 Feb 10 12:59 edit.lok


cat edit.lok
#
#Fri Feb 10 12:59:05 CET 2012
acquired=1328875145953
owner={AES}vIa1WfKmdgbwwTw8L2mLn1KSWZ0dzICRW3YTIffAODU\=
expires=0
exclusive=false


The timestamp shows the time at which it was acquired

I release it, and here we go again with the timestamp showing the release time:

cat edit.lok
#
#Fri Feb 10 13:02:08 CET 2012


Linux file creation and modification date

touch myfile.txt

ls -ltr

-rw-rw-r-- 1 soa soa 0 Feb 10 11:24 myfile.txt

this is the MODIFICATION DATE (which at the beginning is same as creation date)

if you later modify the file, there is no way (in Linux) to retrieve the creation date. You will always get the modification time.

"ls -lact --full-time" will not help

stat myfile.txt will not help

http://bloggerdigest.blogspot.com/2006/10/using-ls-command-by-examples.html gives a good list of ls options

OSB sequencing of JMS messages

A common requirement is to process messages in a strict order.

This post on the OTN forum goes in depth over the possible solutions (I am copying it here just in case the post gets deleted):


By default Weblogic JMS Queues are FIFO. But that is true only if there is only one consumer of the queue.

In case of a clustered environment that is not true and in case of OSB even with a single managed server multiple threads are created for a JMS listener Proxy(by default 16). So there will be 16 instances of the Proxy trying to read messages from the Queue and each will be handed out a message and sequential integrity is disturbed.

There are three ways to overcome this problem:
1. Unit of Order
This is suitable only when you want messages of the same group to be processed sequentially while multiple groups can be processed in parallel.
For e.x. you are getting multiple orders for multiple customers and you want to ensure that the orders of same customer are processed sequentially (in case a customer tries to change the quantity of an order then the latest one should be processed last). In this case you can set UOO as the CustomerID and each customer's order will be processed sequentially but orders of different customers will be still processed in parallel. WLS JMS achieves this by assigning a target queue instance on the cluster for each UOO value. It will assign Q!MS1 to CustID=1, Q!MS2 to CustID=2 and so on. All messages of the same UOO(of the same customer) will go to the same instance on the queue. Furthermore it will ensure that no two messages of the same UOO are released together to the listeners. So if a queue instance has 5 messages each of both Cust=1 and Cust=2, only one message each of Cust1 and Cust2 will be processed by the listeners even if there are 16 listening threads.
Pros and Cons:
Overall performance is improved since you can still achieve some parallel processing.
There will be a slight overhead of processing the UOO headers on the JMS servers.
Can not ensure sequencing of all the messages. (Although you can achieve that by setting the same UOO on all the messages)
If the managed server assigned to a UOO is down, if a publisher tried to put the next message for that UOO, it will fail since it will not try to send that message to any other managed server.

2. Single threaded processing
If you don't want to process even different groups of messages in parallel and if you want absolute sequencing (i.e. irrespective of the CustomerID you want all the messages to be processed in the sequence they arrive) you will need to process them in a single threaded model. The JMS queue should be deployed on only one managed server of the cluster. The JMS proxy listening to the queue should also be deployed on a single managed server(You will need to change the targeting for the EJB created for this Proxy in the Deployments) and there should be a Work Manager for this Proxy with Maximum Thread Constraint set as 1. In the Connection Factory which the Proxy uses, set the Maximum Messages per session to 1. Another approach for Single threaded could be to set the same value of UOO on all of the messages. This will make all the messages to go to the same Q instance in the cluster and also will make sure that even if Proxy has multiple threads, only one message will be processed at a time.
Pros and Cons:
Completely single threaded processing, will take more time since messages will be processed one after the other.
Load balancing will go awry as all the messages will be processed by only one server.

3. Using custom implementation
The most complex way is to create a completely custom implementation. Put all the messages in a DB and then process them one at a time based on timestamp.
Pros and Cons:
It will take more effort to implement than the other two approaches.
It will again need single threaded processing after the messages are put on the DB
Performance wise there will be more impact because of additional DB calls
More complex to maintain

Based on your exact requirements you can choose which approach you want. If you have SOA suite as well them it would be better to move this solution to SOA suite as OESB(Mediator) component of SOA suite has re-sequencing feature.




Thursday, February 9, 2012

Deadlock on AdminServer

DEADLOCK DETECTED:

ExecuteThread: '0' is waiting to acquire lock 'com.bea.wli.config.component.impl.ReferenceMap@333992e9' that is held by thread ExecuteThread: '11'

stacktrace:
com.bea.wli.config.component.impl.ReferenceMap.getAncestorsOrDescendents(ReferenceMap.java:820)



ExecuteThread: '11' is waiting to acquire lock 'com.bea.wli.config.transaction.TransactionManager@4870086e' that is held by thread ExecuteThread: '0'

stacktrace:
com.bea.wli.config.transaction.TransactionManager.enlistAsRead(TransactionManager.java:972)


I assume this happened when someone was deploying a new component.... restarting the Admin was the only way out.

This is not a tragic event (Admin servers are not so important after all :o) ) ... still if you have faced this issue you know you now that are not alone.

Wednesday, February 8, 2012

Cluster Master, Singleton Master....

taking sparse notes here...

Cluster Master:

http://docs.oracle.com/cd/E21764_01/web.1111/e13709/migration.htm#i1034621
"Its role is to orchestrate the server migration process"
Reading this doc is like pure poetry.



Singleton Master:

http://docs.oracle.com/cd/E21764_01/web.1111/e13709/service_migration.htm#i1051470

"The singleton master is a lightweight singleton service that monitors other services that can be migrated automatically."

These services use the ACTIVE Database table to keep renewed the lease:

CREATE TABLE ACTIVE (
SERVER VARCHAR2(150) NOT NULL,
INSTANCE VARCHAR2(100) NOT NULL,
DOMAINNAME VARCHAR2(50) NOT NULL,
CLUSTERNAME VARCHAR2(50) NOT NULL,
TIMEOUT DATE,
PRIMARY KEY (SERVER, DOMAINNAME, CLUSTERNAME)
);


see /opt/oracle/fmw11_1_1_5/wlserver_10.3/server/db/oracle/920/leasing.ddl

and the content of the table looks like:

"SERVER"                      "INSTANCE"                    "DOMAINNAME"                  "CLUSTERNAME"                 "TIMEOUT"                    
"service.SINGLETON_MASTER"    "2756549746869550668/osbpp1ms1""osbpp1do"                    "osbpp1cl"                    "06-MAY-12"                  
"wlsserver.osbpp1ms4"         "-5012701700773599167/osbpp1ms4""osbpp1do"                    "osbpp1cl"                    "06-MAY-12"                  
"service.CLUSTER_MASTER"      "2756549746869550668/osbpp1ms1""osbpp1do"                    "osbpp1cl"                    "06-MAY-12"                  
"wlsserver.osbpp1ms2"         "1291378860276628438/osbpp1ms2""osbpp1do"                    "osbpp1cl"                    "06-MAY-12"                  
"wlsserver.osbpp1ms1"         "2756549746869550668/osbpp1ms1""osbpp1do"                    "osbpp1cl"                    "06-MAY-12"                  
"wlsserver.osbpp1ms3"         "-2011604050071714597/osbpp1ms3""osbpp1do"                    "osbpp1cl"                    "06-MAY-12"               


that is, one row per managed server in the cluster, plus a row for service.SINGLETON_MASTER and one for service.CLUSTER_MASTER (this is also telling us that both SINGLETON_MASTER and CLUSTER_MASTER are osbpp1ms1 in this case.

Tuesday, February 7, 2012

DB: Clustered Indexes or Index-Organized Tables

Reading
http://www.javacodegeeks.com/2012/02/20-database-design-best-practices.html

I stumbled on this statement:

"Use indexes for frequently used queries on big tables. Analyser tools can be used to determine where indexes will be defined. For queries retrieving a range of rows, clustered indexes are usually better. For point queries, non-clustered indexes are usually better."

What is a "clustered index"?

http://en.wikipedia.org/wiki/Database_index#Clustered
"They are known as "index organized tables" under Oracle database."

Pretty good description here:

http://www.orafaq.com/wiki/Index-organized_table

More here:

http://stackoverflow.com/questions/3382939/when-should-i-use-oracles-index-organized-table-or-when-shouldnt-i

"In practice, index organized tables are most likely to be reference data, code look-up affairs."

Timezones and Daylight savings

In XQuery, the dateTime is associated with a TimeZone - expressed as a difference from GMT, the +01:00 below:

fn:current-dateTime()
2012-02-07T11:33:37.829+01:00


to convert this dateTime to GMT, use this trick:

fn:adjust-dateTime-to-timezone(fn:current-dateTime(),xdt:dayTimeDuration('PT0H'))
2012-02-07T10:33:37.829Z

to discover which is your timezone:

fn:implicit-timezone()
PT1H

To convert a String to dateTime:
xs:dateTime("2012-02-07T10:39:27")

To convert a String to date:
xs:date("2012-02-07")

So instead of fn:current-dateTime() you can pass an explicit dateTime:

fn:adjust-dateTime-to-timezone(xs:dateTime("2012-02-07T11:33:37.829+01:00"),xdt:dayTimeDuration('PT0H'))
2012-02-07T10:33:37.829Z

(since I am in +1 timeZone, the hour goes back 1 hour after adjustment)

BEWARE: the difference with GMT changes with the DayLight savings period (23 march to 22 September approximately)

setting the clock to june the 14th, the difference becomes 2 hours:

fn:current-dateTime()
2012-06-14T11:50:36.124+02:00

but our system to adjust dateTime to GMT still works perfectly:

fn:adjust-dateTime-to-timezone(fn:current-dateTime(),xdt:dayTimeDuration('PT0H'))
2012-06-14T09:50:36.124Z

Monday, February 6, 2012

SAMBA mountpoints on Linux

How do I find out which SAMBA mountpounts I have on my box?

Using mount you shall find some Common Internet File System (CIFS) entries :

[soa@hqchACMESOA104 ffmw]$ mount

/dev/mapper/rootvg-rootlv on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/mapper/rootvg-tmplv on /tmp type ext3 (rw)
/dev/mapper/rootvg-optlv on /opt type ext3 (rw)
/dev/mapper/rootvg-homelv on /home type ext3 (rw)
/dev/mapper/rootvg-varlv on /var type ext3 (rw)
/dev/cciss/c0d0p1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
//acme1999.ACME.com/zdata/ER/ACMESOA/3786 on /data/ffmw/ACME1 type cifs (rw,mand,noexec,nosuid,nodev)
//chornl1999.ACME.com/zdata/ER/ACMESOA/0983 on /data/ffmw/ACME2 type cifs (rw,mand,noexec,nosuid,nodev)


[soa@hqchACMESOA104 ffmw]$ cat /etc/fstab

/dev/rootvg/rootlv / ext3 defaults 1 1
/dev/rootvg/tmplv /tmp ext3 defaults 1 2
/dev/rootvg/optlv /opt ext3 defaults 1 2
/dev/rootvg/homelv /home ext3 defaults 1 2
/dev/rootvg/varlv /var ext3 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/rootvg/swaplv swap swap defaults 0 0
//acme1999.ACME.com/zdata/ER/ACMESOA/3786 /data/ffmw/ACME1 cifs rw,domain=ACME,username=CHAVEACMESOA,password=AVENes0a,auto,users 0 0
//emcal1999.ACME.com/zdata/ER/ACMESOA/0983 /data/ffmw/ACME2 cifs rw,domain=ACME,username=CHORNACMESOA,password=ORNNes0a,auto,users 0 0