Thursday, June 30, 2011

OSB: which Proxy Services types are eliglible as a target for a Service Callout ?

surely, NOT a Messaging Type.
If you declare it as a "Any XML" with "local" protocol, it should work



Wednesday, June 29, 2011

Life of an IT consultant





Just remember that life is NOW, not TOMORROW.

Take the time to call a friend, send a postcard to your uncle. IT is not all that great. Love is better.

Coherence Cache viewer

googling around I find:
http://sourceforge.net/projects/sibyl/develop

http://www.sl.com/products/coherenceviewer.shtml (you must require evaluation)

http://sourceforge.net/projects/coherenceviewer/develop


A great Coherence expert, Michael, tells me:

I'm not sure if there is any built in functionality that can help with it. The easiest way is to join the cluster with Coherence Console (coherence.sh) and use 'maps' and 'list' commands.

Read this:
http://coherence.oracle.com/pages/viewpage.action?pageId=16684

and this:
http://mazanatti.info/index.php?/archives/65-Connecting-a-console-to-an-OSB-Coherence-cluster.html

Another way would be to implement very simple java app to browse the cache... that shouldn't be to complicated ;)


no mqjbnd in java.library.path

this error occurs only if you use BINDINGS mode to connect to QueueManager running on the same box. If you use TCP, no Native Library is required.

no mqjbnd in java.library.path


copy mqjbnd.dll, mqjexitstub02.dll and PgmIpLayer.dll to c:/eclipse directory (or anywhere in your System property java.library.path, do a System.out.println(System.getProperty("java.library.path"))  to find out...  )

mqjbnd.dll: Can't find dependent libraries

just install locally MQ




Oracle DMS Application

well well, I discovered that there is a "DMS Application" deployed on WebLogic, and if you http://localhost:7001/dms (provide your weblogic login at the prompt)
you end up in a primitive but interesting Web Application with plenty of documentation on all the MBeans available

Let alone the capacity to navigate and interrogate MBeans, the dms webapp is also valuable for all the documentation it provides (click on Metrics Definition)

For example the JVM_MemoryPool and the JVM_MemorySet bring valuable information on the JVM memory utilization :


JVM_MemoryPool

Name Host Process memory_manager type usedAfterCollect, KB usedNow, KB usedPeak, KB valid JVM JVM_Memory ServerName
Code Cache localhost AdminServer:7009 CodeCacheManager Non-heap memory 0 18555 18558 TRUE JVM memory AdminServer
PS Eden Space localhost AdminServer:7009 PS MarkSweep, PS Scavenge Heap memory 0 86964 526385 TRUE JVM memory AdminServer
PS Old Gen localhost AdminServer:7009 PS MarkSweep Heap memory 0 314223 314223 TRUE JVM memory AdminServer
PS Perm Gen localhost AdminServer:7009 PS MarkSweep Non-heap memory 0 290873 290873 TRUE JVM memory AdminServer
PS Survivor Space localhost AdminServer:7009 PS MarkSweep, PS Scavenge Heap memory 2671 2671 101035 TRUE JVM memory AdminServer
Top | Metric Definitions


Wed Jun 29 18:26:46 CEST 2011
Copyright © 2002, 2009, Oracle and/or its affiliates. All rights reserved.



JVM_MemorySet
Name Host Process committed, KB init, KB max, KB used, KB JVM JVM_Memory ServerName
Heap memory localhost AdminServer:7009 1230528 1048576 1864192 396667 JVM memory AdminServer
Non-heap memory localhost AdminServer:7009 302464 133568 573440 302196 JVM memory AdminServer
Top | Metric Definitions

Tuesday, June 28, 2011

OSB Custom XPath Functions

I have followed the instructions here:

http://download.oracle.com/docs/cd/E21764_01/doc.1111/e15866/custom_xpath.htm


added an extra category and function to the  $ORACLE_HOME/Oracle_OSB1/config/xpath-functions/osb-built-in.xml  file,
in the same $ORACLE_HOME/Oracle_OSB1/config/xpath-functions/ directory I put the JAR with the function

the good news is that it really works! I find these custom XPath function a powerful way to carry out message manipulations too complex to do in XQuery.

Java rules! Use the Force!



to check if anything went wrong, grep for something like:
CustomXPathFunctionManager: Failed to register custom XPath function

also:
make sure no blank spaces are in the XML file

for arrays, make sure you use the notation [Ljava.lang.String;

visualvm you are running visualvm using Java Runtime Environment (jre)

you double click on visualvm and you get this message - without an explanation of how to use a JDK instead.
Bummer.

After some research I find out that
visualvm_132\visualvm_132\etc
contains a file
visualvm.conf
with an entry:

# default location of JDK/JRE, can be overridden by using --jdkhome <dir> switch
#jdkhome="/path/to/jdk"

I replace it with

jdkhome=C:/Oracle4/Middleware/jdk160_21

and it works....


OSB, Java Callout, static variables and classloaders

We have a huge (10,000 element) lookup table to enrich a payload.
We have tried to store it in Coherence cache and query it with XQuery, but performance is unacceptable and memory impact is huge,
also because XQuery doesn't allow you to create indexes on a XML document for fast searches (correct me if I am wrong).

So we are thinking of storing the whole table in a Java class as a:
static HashMap<String, XmlObject> cache = new HashMap<String, XmlObject>();

where the String is a unique key for the table (an id).

and when I need a specific element I use a lookup:

public static XmlObject lookupElement(String id) {
return cache.get(id);
}

We initialize the cache with a static init(XmlObject[] objectsToCache).

My question is:
the Java class we use as a cache container will not be garbage collected at some point in time, leaving us with no cache at all?
Also, if this Java class is accessed within a Proxy Service which is implemented as a MDB (an independent Enterprise application deployed in WebLogic with a ejb.jar module),
the classloader will not be different, hence a new instance of the class will be accessed?

My guess is that all other Proxy Services - I mean other than MDBs - are "deployed" - in fact interpreted at runtime - in the same Enterprise Application as ALSB Routing (or some other EAR starting with ALSB)...

If you deem too risky this approach of using static variables in a Java class as cache containers, which other pattern can I use?
This solution seems extremely fast.... performance is a great concern here. We cannot afford to have to marshal/unmarshal stuff or making a service invocation for each lookup.

If anybody can help, I would be grateful ( see also my post http://forums.oracle.com/forums/message.jspa?messageID=9690744#9690744 )
Thank you soooo much!
pierre




Monday, June 27, 2011

OSB: Business Service providing a caching wrapper to a Proxy Service

I have implemented a Proxy Service, and now I want to be able to cache
its response.
The only way is through a "Cache Enabled" Business Service.

Normally a Business Service is meant to expose EXTERNAL services, so
it doesn't happen so often to expose a LOCAL Proxy Service....
Obviously I wan to use the LOCAL protocol for performance reasons.

Well, it turns out that it is impossible to connect from a BS to a PS
using "local".
I had to turn to the sb protocol (=RMI), which is a bit of a pain
because it involves serialization of payload.
I am not too worried because in any case I am caching the result,
still I feel puzzled about the lack of support for "local" protocol
between BS and PS.

copy/paste not working with XMing

starting a CMD and running
Xming.exe" :0 -clipboard -multiwindow -ac

and using CTRL-V to paste (forget the right-click/Paste useless shortcut) did the trick



Friday, June 24, 2011

BEA-380001: A Transport Exception occurred during an SB Transport message processing

I was calling a BS from a PS1 (route) and I was always getting this error. The BS was using SB protocol to talk to another PS2.

It turned out that in PS1 I was inserting a wsa:SoapAction header.
Removing the header fixed the issue.
I am not sure at which point it was causing trouble.... one needs to turn on debug flags to trace operations.


OSB and resequencing of JMS messages

the feature exists in ESB:
http://download.oracle.com/docs/cd/E12524_01/doc.1013/e12638/sequencer.htm


you can use Unit Of Order instead:
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/jms/uoo.html

see this extensive dissertation:
http://forums.oracle.com/forums/thread.jspa?threadID=2136854&tstart=165
(the post from 816687 )

the let statement in XQuery

if you are trying to update a variable in a for loop in XQuery, you will face a lot of frustration

if you do this:

let $count := 1

for $bla in $mumble
     let $count := $count + 1


IT WILL NOT WORK! On the left hand side ot the "let" you will keep updating a local scope variable, while in the right hand side of the "let" you will access the global $count variable declared above the "for"

Read the excellent XQuery book http://www.javamonamour.org/2010/05/excellent-xquery-book.html by Priscilla Walmsley, especially chapter 9 "Working with Positions and Sequence Numbers" is dedicate to this quirk.

XQuery is not a normal programming language, there are operations that are simply not allowed. It can be frustrating sometimes - actually quite often - and the learning curve is not flat.



Using of XQuery index-of to implement a quick lookup service

Locating an element based on a value can be very expensive (full table scan each time)

this:
$retrievePtcarSummaryResponse1/ns0:RetrievePtcarSummaryResult/ns0:PtcarSummary[ns0:Id=$item]
is very slow if you have a lot of PtcarSummary.


I have tried to implement a lookup mechanism by building a sequence of the values being looked up:

let $mySequence := $retrievePtcarSummaryResponse1/ns0:RetrievePtcarSummaryResult/ns0:PtcarSummary/ns0:Id/text()


this will build a sequence made by all Id in all the PtcarSummary


then using

for $item in 1 to $myMax
        let $pos := fn:index-of($mySequence, xs:string($item))
    return
    if ($pos) then
    $retrievePtcarSummaryResponse1/ns0:RetrievePtcarSummaryResult/ns0:PtcarSummary[$pos]
    else
......


I was hoping to optimize the search.
Bummer.
I keep getting OutOfMemoryException for large (1600) sequences.

In fact I read here that sequences are quite poor in memory allocation.... bummer....

I was hoping XQuery was a SQL for XML, but it is not.
SQL support indexes - without them any DB would be stuck.
XQuery support for indexes is extremely limited - the language doesn't even support a HashMap, for Christ sake....

OSB profiling and monitoring your Proxy Service Message Flow

I was quite impressed by what you can achieve with the Monitoring
console, if you activate Monitoring at "Action" level....
you get execution time of every action in your Message Flow, including
execution time of each Service Callout...
Just inject a constant load on your system, and enjoy.

Thursday, June 23, 2011

JVM CPU occupation by thread

This very critical information is provided by VisualVM, an excellent tool:

http://visualvm.java.net/docindex.html

JConsole is really too primitive a tool.

Xquery, the need to cast your variables

Today I have wasted 1 hour on this:

the inputs are:



27
Al Quran



1
La Tregua





Mohamed



Levi




my Xquery does:

THIS is WRONG:

let $myAuthorIndex := data($books/book[name="Mohamed"]/authorIndex)
let $myAuthors := $authors/author[$myAuthorIndex]


well, this will not work.... you will get ALL AUTHORS.
The trick is to CAST $myAuthorIndex to an integer, otherwise it will be considered a string and ignored


THIS is correct:

let $myAuthorIndex := xs:int(data($books/book[name="Mohamed"]/authorIndex))
let $myAuthors := $authors/author[$myAuthorIndex]

OSB and Coherence: example of $outbound when the cache is HIT (see tran:cache-originated)

pay attention to cache-token and cache-originated



  
    RetrievePtcarSummary
  
  
    http://acme.com:10204/webservice2/InfraService.svc
    request-response
    best-effort
    
      
        text/xml
        "http://www.acme.com/RetrieveBlaSummary"
      
      2011-06-22
    
    
      
        
        
        private
        close
        1395654
        text/xml; charset=utf-8
        Thu, 23 Jun 2011 14:51:40 GMT
        Microsoft-IIS/6.0
      
      0
      OK
      utf-8
      2011-06-22
      true
      200
    
  
  
    false
  
 




OSB testing services through HTTPClient

I have created a HTTP Facade to my Proxy Service,
and I invoke it with a HTTP Client, I enable monitoring and I observe the performance of the service via the Operation Console / Server Health

This is the Java client

package com.bla.gu.pt;

import java.util.Date;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;



public class GUPT {
    public static final String FACADE_URL = "http://acme.com:7009/InterfacesGU/GUAnyXMLFacade";

    public static void main(String[] args) throws Exception {
        HttpContext localContext = new BasicHttpContext();
        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(FACADE_URL);
        StringEntity entity = new StringEntity("<BLANotification Type='TrainItinerary' DateTime='2007-10-26T08:36:28' Id='3' ValidityDate='2004-02-14'/>");
        httppost.setEntity(entity );
        HttpResponse response = httpclient.execute(httppost, localContext);
        System.out.println("getReasonPhrase " + response.getStatusLine().getReasonPhrase());
        System.out.println("getStatusCode " + response.getStatusLine().getStatusCode());
        HttpEntity resultEntity = response.getEntity();
        System.out.println(resultEntity);
    }
}




In case of success, I get

getReasonPhrase OK
getStatusCode 200


In case of failure, I get

getReasonPhrase Internal Server Error
getStatusCode 500


In my proxy, I validate the payload; if validation fails, I get a HTTP 500

validate $body/* against BLANotification Schema









Wednesday, June 22, 2011

OSB: getting data from $body

bear in mind these differences when passing $body to XQuery functions:

assume:
 $body  = <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">  <BLANotification Type="TrainItinerary" DateTime="2007-10-26T08:36:28" Id="3" ValidityDate="2004-02-14"/></soapenv:Body>

then:
 $body/. = $body
 $body/* = $body/node() = <BLANotification Type="TrainItinerary" DateTime="2007-10-26T08:36:28" Id="3" ValidityDate="2004-02-14"/>

Tuesday, June 21, 2011

Amazon EC2 micro instance

I wanted to give a try to Amazon Micro Instances... below a threshold usage, they are free, and fun to use.


see also http://www.keywordintellect.com/amazon-web-services/how-to-set-up-an-amazon-ec2-instance/




http://www.keywordintellect.com/amazon-web-services/managing-an-amazon-ec2-instance-using-putty-ssh/

login as ec2-user, not as root

Monday, June 20, 2011

Detected recursive attempt by part org.eclipse.wst.wsdl.ui.internal.WSDLEditor to create itself

it was caused by a invalid import (bad schemaLocation) in a WSDL....

it is quite frustrating how Eclipse is unable to properly report some errors.... give me back my IntelliJ!

OSB WCF WSDL

When you export the WS resources from WCF you get these files:

results.discomap
PippoService.disco
PippoService.wsdl
PippoService.xsd
PippoService.zip
PippoService0.wsdl
PippoService0.xsd
PippoService1.xsd
PippoService2.xsd

The problem is that internally the WSDL and XSD don't refer to these filenames, but to the (horrible) syntax

<xsd:import schemaLocation="PippoService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />


Luckily they give you a MAP:

the content of PippoService.disco:

<?xml version="1.0" encoding="utf-8"?>
<DiscoveryClientResultsFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <Results>
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://localhost:3720/PippoService.svc?xsd=xsd0" filename="PippoService.xsd" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://localhost:3720/PippoService.svc?xsd=xsd2" filename="PippoService0.xsd" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://localhost:3720/PippoService.svc?xsd=xsd3" filename="PippoService1.xsd" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.DiscoveryDocumentReference" url="http://localhost:3720/PippoService.svc?disco" filename="PippoService.disco" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.ContractReference" url="http://localhost:3720/PippoService.svc?wsdl" filename="PippoService.wsdl" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.ContractReference" url="http://localhost:3720/PippoService.svc?wsdl=wsdl0" filename="PippoService0.wsdl" />
   <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://localhost:3720/PippoService.svc?xsd=xsd1" filename="PippoService2.xsd" />
 </Results>
</DiscoveryClientResultsFile>



so, for referenceType:
System.Web.Services.Discovery.ContractReference=WSDL
System.Web.Services.Discovery.SchemaReference=XSD
you build a map, then you must replace the schemaLocation with the filename in ALL our WSDL and XSDs.


For instance in the WSDL I have:

<wsdl:import namespace="http://ACME/Bla" location="PippoService.svc?wsdl=wsdl0"/>

this should become

<wsdl:import namespace="http://ACME/Bla" location="PippoService0.wsdl"/>



This is not all:
in PippoService0.wsdl we have:

 <wsdl:types>
   <xsd:schema targetNamespace="http://ACME/Bla">
     <xsd:import namespace="http://ACME/Mumble"/>
     <xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
     <xsd:import namespace="http://ACME/Snort"/>
     <xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
   </xsd:schema>
 </wsdl:types>


without any schemaLocation; To discover what to put as schemaLocation you must determine the targetNamespace for each XSD,
and add schemaLocation="PippoServiceX.xsd"  where X depends on the mentioned targetNamespace mapping.


All this can be (easily?) scripted, as we don't want to do this crap manually - we are no monkeys :o)





error running a VirtualBox image: E_FAIL 0x80004005

unknown error creating VM: VERR_VMX_MSR_LOCKED_OR_DISABLED
Component: Console

Interface :
   

IConsole {515e8e8d-f932-4d8e-9f32-79a52aead882}


0x80004005 is a Windows error meaning "unspecified error"




Reducing the Virtual Machine memory to less than 4GB seems to fix the problem...

now I get FATAL: No bootable medium found! System halted.





Friday, June 17, 2011

Software Engineering in an SOA Environment

http://www.oracle.com/technetwork/topics/entarch/oracle-pg-soa-sw-engineering-r3-0-176714.pdf


It's quite informative and it goes in depth - but more for the Business Analyst than for the Architect or Developer


A Quick Start Guide to Cloud Computing by Dr Mark I Williams

http://www.amazon.com/Quick-Start-Guide-Computing-ebook/dp/B004X4UCFM




some valuable quotes:

'Cloud computing is a style of computing where
scalable and elastic IT-enabled capabilities are provided
"as a service" to multiple external customers using Internet
technologies.' In simple terms, cloud computing enables
businesses of all sizes to quickly procure and use a wide
range of enterprise-class IT systems on a pay-per-use
basis from anywhere at any time.

"The NIST draft definition goes on to describe these five
essential characteristics (on-demand self-service, broad
network access, resource pooling, rapid elasticity and
measured service), three service models (Software as
a Service – SaaS, Platform as a Service – PaaS and
Infrastructure as a Service – IaaS), and four deployment
models (Private, Community, Public and Hybrid Cloud);"









Java send JMS: how to send a jms message to WebLogic

package com.acme.jms;


import java.util.Hashtable;

import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.naming.Context;
import javax.naming.InitialContext;

public class SendJmsMessageHeaderProperties {
    public static void main( String[] args ) throws Exception {
        QueueConnection queueCon = null;
        try {
            // get the initial context, refer to your app server docs for this
            Hashtable<String, String> ht = new Hashtable<String, String>();
            ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
            ht.put(Context.PROVIDER_URL, "t3://localhost:7001");       
            Context ctx = new InitialContext(ht);

            // get the connection factory, and open a connection
            QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup( "weblogic/jms/XAConnectionFactory" );
            queueCon = qcf.createQueueConnection();

            // create queue session off the connection
            QueueSession queueSession = queueCon.createQueueSession( false, Session.AUTO_ACKNOWLEDGE );

            // get handle on queue, create a sender and send the message
            Queue queue = (Queue) ctx.lookup( "RudyInQueue" );
            QueueSender sender = queueSession.createSender( queue );

            Message msg = queueSession.createTextMessage( "<Hello>I am a pig</Hello>" );

            sender.send( msg );

            System.out.println( "sent the message" );
        }
        finally {
            // close the queue connection
            if( queueCon != null ) {
                queueCon.close();
            }
        }
    }
}


here is the CLASSPATH:





<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
        <attributes>
            <attribute name="owner.project.facets" value="java"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
    <classpathentry kind="lib" path="lib/javax.jms_1.1.1.jar"/>
    <classpathentry kind="lib" path="lib/weblogic.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.weblogic.security.identity_1.1.2.1.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.weblogic.workmanager_1.9.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.weblogic.workmanager.ja_1.9.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.transaction_2.7.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.weblogic.rmi.client.ja_1.8.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.weblogic.rmi.client_1.8.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.weblogic.security.wls_1.0.0.0_6-1-0-0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.utils.full_1.9.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.weblogic.security_1.0.0.0_6-1-0-0.jar"/>
    <classpathentry kind="lib" path="lib/wlclient.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.utils.classloaders_1.8.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.management.core_2.8.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.descriptor_1.9.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.logging_1.8.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.timers_1.7.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.weblogic.socket.api_1.2.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.weblogic.security.digest_1.0.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.weblogic.lifecycle_1.4.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.store_1.7.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.common.security.api_1.0.0.0_6-1-0-0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.utils.wrapper_1.4.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.messaging.kernel_1.8.0.0.jar"/>
    <classpathentry kind="lib" path="lib/com.bea.core.utils.expressions_1.4.0.0.jar"/>
    <classpathentry kind="output" path="build/classes"/>
</classpath>






Java client for Websphere MQ

PutMessage sends 10 messages to the queue
MQReader reads (and consumes) 1 message at a time (getAllMessages() still fails on the getQueueDepth()... investigating...)



package com.acme.mq;

import com.ibm.mq.*;

import java.io.*;
import static com.acme.mq.MQConstants.*;


public class PutMessage {

    private String qManager = MQ_queueManager;
    private String qName = MQ_queue;
    private String qmessageFile = "c:/pierre/mqfile.txt";


    public static void main(String args[]) throws Exception {
        System.out.println("java.library.path=" + System.getProperty("java.library.path"));
        PutMessage pM = new PutMessage();

        pM.runNow();
    }

    public void runNow() throws Exception {
            System.out.println("Connecting to queue manager: " + qManager);
            MQQueueManager qMgr = MQReader.setup();
            int openOptions = 17;
            System.out.println("Accessing queue: " + qName);
            MQQueue queue = qMgr.accessQueue(qName, openOptions);
            File file = new File(qmessageFile);
            for (int i = 0; i < 10; i++) {
                String qmessage = getContents(file) + " " + i;
                MQMessage msg = new MQMessage();
                msg.writeString(qmessage);
                MQPutMessageOptions pmo = new MQPutMessageOptions();
                System.out.println("Sending message: " + qmessage);
                queue.put(msg, pmo);
            }
            System.out.println("Closing the queue");
            queue.close();
            System.out.println("Disconnecting from the Queue Manager");
            qMgr.disconnect();
            System.out.println("Done!");
    }

    private String getContents(File aFile) {
        StringBuffer contents;
        contents = new StringBuffer();
        BufferedReader input = null;
        try {
            input = new BufferedReader(new FileReader(aFile));
            for (String line = null; (line = input.readLine()) != null;) {
                contents.append(line);
                //contents.append(System.getProperty("line.separator"));
            }
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            try {
                if (input != null)
                    input.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

        return contents.toString();
    }
}





package com.acme.mq;

import com.ibm.mq.*;

import java.text.*;
import java.io.*;
import java.util.Hashtable;
import static com.acme.mq.MQConstants.*;

public class MQReader {
     
    public static void main(String[] args) throws Exception {
        MQReader mqReader = new MQReader();
        mqReader.getMessage();
    }

   
    public void getAllMessages() throws MQException, IOException {
        MQQueueManager qm = setup();
        int options = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_INQUIRE;
        MQQueue q = qm.accessQueue(MQ_queue, options, null, null, null);
        int depth = q.getCurrentDepth();
        DecimalFormat indexFormat = new DecimalFormat(Integer.toString(depth).replaceAll(".", "0"));
        System.out.println("found messages " + depth);
       
        for (int index = 0; index < depth; index++) {
            MQMessage msg = new MQMessage();
            q.get(msg, new MQGetMessageOptions());
            int msgLength = msg.getMessageLength();
            String text = msg.readStringOfByteLength(msgLength);
            System.out.println("message#" + index + "  text=" + text);
        }
    }


   
    public void getMessage() {
          try
          {
             MQQueueManager qm = setup();
             MQQueue q = qm.accessQueue(MQ_queue, MQC.MQOO_INPUT_AS_Q_DEF);

             MQMessage msg = new MQMessage();

             q.get(msg);

             System.out.println("Message: " + msg.readLine());

             q.close();
             qm.disconnect();
          }
          catch(MQException e)
          {
             System.out.println("MQ Error: cc=" + e.completionCode + ", reason=" + e.reasonCode);
          }
          catch(java.io.IOException e)
          {
             System.out.println("IO Error: " + e);
          }        
    }
   


    public static MQQueueManager setup() throws MQException {
        MQEnvironment.hostname = MQ_hostname;
        MQEnvironment.channel = MQ_channel;
        MQEnvironment.port = MQ_port;
        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);
        MQEnvironment.properties = props;
        MQQueueManager qm = new MQQueueManager(MQ_queueManager);
        return qm;
    }
       
}





package com.acme.mq;

public class MQConstants {
    public static String MQ_hostname = "bla.acme.com";
    public static String MQ_channel = "A123.TO.QMIA00D";
    public static int    MQ_port = 1435;
    public static String MQ_queueManager = "QMIA00D";
    public static String MQ_queue = "AQ.A123.BLA.NOTIFICATION.EVENT";
     
}





I have added to the classpath ALL the MQ jars I could find in my MQ installation...

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    <classpathentry kind="lib" path="lib/CL3Export.jar"/>
    <classpathentry kind="lib" path="lib/CL3Nonexport.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.axis2.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.commonservices.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.defaultconfig.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.headers.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.jmqi.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.jms.Nojndi.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.pcf.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.postcard.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.soap.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mq.tools.ras.jar"/>
    <classpathentry kind="lib" path="lib/com.ibm.mqjms.jar"/>
    <classpathentry kind="lib" path="lib/connector.jar"/>
    <classpathentry kind="lib" path="lib/dhbcore.jar"/>
    <classpathentry kind="lib" path="lib/fscontext.jar"/>
    <classpathentry kind="lib" path="lib/jms.jar"/>
    <classpathentry kind="lib" path="lib/jndi.jar"/>
    <classpathentry kind="lib" path="lib/jta.jar"/>
    <classpathentry kind="lib" path="lib/ldap.jar"/>
    <classpathentry kind="lib" path="lib/providerutil.jar"/>
    <classpathentry kind="lib" path="lib/rmm.jar"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

Tuesday, June 14, 2011

OSB setting JMS property on JMS message and filtering (message selector) on the consumer proxy

This is how to configure the Message Selector on the receiving Proxy:


this is how to set the JMS property in the Transport Options before you route to the Business Service posting to the JMS queue



Monday, June 13, 2011

Nuclear Power? Ask Italy

and Italy today said NO with an overwhelming 96% of the votes AGAINST:

- nuclear power
- privatization of water
- immunity for politicians


20 years of media manipulation by a rich tycoon didn't manage to destroy Italy, just like 20 years of Mussolini before.



Saturday, June 11, 2011

The Most Important Characteristics of an Architect

Reblogging from one of my favourite blogs, the Build Blog:

http://blog.buildllc.com/2011/06/the-most-important-characteristic-of-an-architect/


"A good architect is someone who rolls up their sleeves on site and helps problem solve."

"The ability to put a project together in your head, identify the issues and bird-dog the solutions is what differentiates a professional architect from “kid’s playing” (a term we like to use for architects who don’t actually solve problems)."

90% of the architects I have met in my life have never spent a minute of their time on the project sitting next to a developer - Ivory Tower architects indeed. The few architects who are taking time to gather feedback and suggestions from developers have my deepest respect.

I am too often confronted with documents which give an extremely complex 3000 feet view of a system, but carefully avoid addressing even the most fundamental implementation details. Those documents are just a copy and paste of a template.

Here a great podcast in 4 sections about "who is an Architect?"


Here a priceless article by Martin Fowler: Who Needs Architects?

Thursday, June 9, 2011

What is the "Execute-Save" button in the OSB Test Console?

At last I found out: instead of displaying the entire response in the Browser, it shows only a snippet and gives you a button to save the entire response to a file...

The SOAP action specified on the message, '', does not match the HTTP SOAP Action

this http://social.msdn.microsoft.com/forums/en-US/wcf/thread/ed32328d-e3ad-47dd-bcb0-3db9e6205f9c/
post helped me a lot:

in my WSDL I was using

    wsdl:binding name="MyServiceBinding" type="tns:IMyService"
        soap:binding style="document"
            transport="http://schemas.xmlsoap.org/soap/http"


which meant that not only I must specify the HTTP header SOAPAction: "http://www.bla.com:MyAction"

but I need to specify also in the SOAP Envelope the header:

<soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>http://www.bla.com:MyAction</wsa:Action>
</soap:Header>



(make sure you pick up the right wsa namespace, there are many flavors around)





OSB and MQ resources

MQ and JCA
http://download.oracle.com/docs/cd/E12839_01/integration.1111/e10231/adptr_mq.htm

OSB and JCA
http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/jcatransport/transport.html


OSB and MQ Transport
http://download.oracle.com/docs/cd/E14571_01/doc.1111/e15866/mq.htm#OSBDV1117

Using the MQ JMS Interface
http://download.oracle.com/docs/cd/E14571_01/doc.1111/e15866/mq.htm#i1040057



WebSphere MQ Fundamentals (IBM Red Book)
http://www.redbooks.ibm.com/redbooks/SG247128/wwhelp/wwhimpl/java/html/wwhelp.htm
http://www.redbooks.ibm.com/redbooks/pdfs/sg247128.pdf

Wednesday, June 8, 2011

WebLogic, OSB and Syslog-ng

About Syslog-ng

Download software for Linux from here

For Windows you can try WinSyslog

Here some musing over WebLogic and Syslog

Here the SyslogAppender for Log4j


more to come.....

application/xml vs text/xml

Just reblogging this precious information:

"XML has two MIME types, application/xml and text/xml. These are often used interchangeably, but there is a subtle difference which is why application/xml is generally recommended over the latter.

Let me explain why: according to the standard, text/*-MIME types have a us-ascii character set unless otherwise specified in the HTTP headers. This effectively means that any encoding defined in the XML prolog (e.g. ) is ignored. This is of course not the expected and desired behaviour.

To further complicate matters, most/all browser implementations actually implement nonstandard behaviour for text/xml because they process the encoding as if it were application/xml.

So, text/* has encoding issues, and is not implemented by browsers in a standards-compliant manner, which is why using application/* is recommended.

Grauw"


That's yet another of those things which make SOAP so exciting: a poor standard poorly implemented poorly defined and poorly respected. It must be on purpose, I can't believe engineers are so stupid.

Tuesday, June 7, 2011

The WebLogic Munger Subsystem

Today my attention was attracted by this message:

07-Jun-2011 09:39:30 o'clock CEST Warning Munger BEA-2156203 A version
attribute was not found in element ejb-jar in the deployment descriptor in C:\Or
acle2\Middleware\user_projects\domains\soadev\servers\AdminServer\tmp\_WL_user\_
ALSB_1307126572130\w02ajb\ejb.jar/META-INF/ejb-jar.xml. A version attribute is r
equired, but this version of the Weblogic Server will assume that the JEE5 is us
ed. Future versions of the Weblogic Server will reject descriptors that do not s
pecify the JEE version.



What - or who - on Earth is MUNGER?

Is he Hieronymus Munger, eminent Dutch painter?

Or perhaps is he Martin Munger King, human rights activist in USA?

The only documentation I found on MUNGER is this

http://download.oracle.com/docs/cd/E21764_01/apirefs.1111/e14397/Munger.html

"The Munger1.0 catalog contains messages in the range BEA-2156200 - BEA-2156249. Messages in this catalog are part of the weblogic.application.descriptor Internationalization package and the weblogic.application.descriptor Localization package."


I bet tomorrow morning I will still be excruciating on "who is actually MUNGER"?

fn-bea:inlinedXML

If you want to manipulate XML in a XQuery as a string, and then return it to OSB as an element, you need to explicitly convert it to an XMLObject using fn-bea:inlinedXML().
Make sure that your XML string is self sufficient, with all the namespace declaration, because inlinedXML() cannot access the globally declared namespaces (even those internal to OSB, like ctx).

xquery version "1.0" encoding "Cp1252";
(:: pragma  type="xs:anyType" ::)

declare namespace xf = "http://tempuri.org/OSB%20Project%201/myXQ/";
declare namespace ctx = "http://www.bea.com/wli/sb/context";

declare function xf:myXQ($string1 as xs:string)
    as element(*) {
        let $myXMLASString := 'ciao'
 
       return fn-bea:inlinedXML($myXMLASString)        
};

declare variable $string1 as xs:string external;

xf:myXQ($string1)



Incidentally, inlinedXML can be also used to turn < into < :



let $a := <c>asdf</c>
return fn-bea:inlinedXML($a)


the result is asdf