Wednesday, February 28, 2018

Oracle SOA - BPEL - forEach or FlowN executing the same Partnerlink in parallel

Problem:

When you try execute a Partnerlink in parallel inside a forEach or FlowN, you must set the property NonBlockingInvoke = true at the Partnerlink.

But, when you try to execute it, you receive this error:

<Error> <oracle.soa.bpel.engine.dispatch> <BEA-000000> <Failed to handle message class com.collaxa.cube.engine.dispatch.message.invoke.NonBlockInvokeMessage, Error message : Failed to create "java:comp/env/ejb/local/bpel/CubeDeliveryBean" bean; exception reported is: "javax.naming.NameNotFoundException: remaining name: ejb/local/bpel/CubeDeliveryBean


Solution:

By default BPEL Partnerlinks are defined at Global level. 

You must move the Partnerlink definition from Global to a local scope inside the forEach or FlowN, 
inside the  element 

<partnerLinks>
...
</partnerLinks>

Hope it helps.


Tuesday, June 7, 2016

WSO2 DSS - Complex Data Support with Oracle PL/SQL



WSO2 DSS no soporta datos complejos como IN de datos al ejecutar un Procedure.

Necesitabamos una forma de poder hacerlo y esta es la que mas se adecuo a nuestras necesidades.



La solucion consiste en convertir los datos complejos a CLOB y utilizar la funcionalidad de convertir Objetos a XML y viceversa que provee Oracle DB.

Como ejemplo vamos a crear lo necesario para poder dar de alta un cliente a traves de un procedure que tiene datos complejos.

1) Oracle DB

Datos del cliente.


create or replace TYPE o_client AS OBJECT ( id NUMBER(10), firstname VARCHAR2(30), lastname VARCHAR2(30) );
/


Tabla para soportar alta de muchos clientes

create or replace TYPE t_client AS TABLE OF o_client;
/


Objecto necesario para soportar la conversion de Objeto a XML para la Collection

create or replace TYPE c_client AS OBJECT ( collection t_client);
/


Respuesta del Procedimiento

create or replace TYPE o_client_r AS OBJECT (result VARCHAR2(30));
/


Package y Procedures

Tenemos el procedure insert_client que es el que recibe y devuelve los datos complejos.

Para hacer que los datos complejos se puedan usar en formato simple los convertimos a CLOB utilizando el procedure insert_client_dss.

create or replace package clients as
procedure insert_client(request t_client,response out o_client_r);
procedure insert_client_dss(request clob,response out clob);
function trim_cdata(cdata in clob) return clob;
end clients;

/

create or replace package body clients as

procedure insert_client(request t_client,response out o_client_r) as
begin
response := o_client_r('OK');
end insert_client;

procedure insert_client_dss(request clob,response out clob) as
v_c_client c_client;
v_o_client_r o_client_r;

cxml xmltype;
begin
if request is not null then
cxml := xmltype(clients.trim_cdata(request));
cxml.toObject(v_c_client);
end if;

clients.insert_client(v_c_client.collection, v_o_client_r);

if v_o_client_r is not null then
response := xmltype(v_o_client_r).getstringval();
end if;
end insert_client_dss;

function trim_cdata(cdata in clob) return clob as
rdata clob;
begin
rdata := replace(cdata,'<![CDATA[','');
rdata := replace(rdata,']]>','');
return rdata;
end;

end clients;

/


Codigo para ver como necesitamos armar el XML a enviar.

declare
t_1 t_client;
o_1 o_client;
c_1 c_client;

v_xml XMLTYPE;
BEGIN
t_1 := t_client();
t_1.extend(2);
o_1 := o_client(1,'Juan Pablo','Vadell');
t_1(1) := o_1;
o_1 := o_client(2,'Cesar','Trono');
t_1(2) := o_1;
c_1 := c_client(t_1);
v_xml:=XMLTYPE(c_1);
DBMS_OUTPUT.put_line('<![CDATA[' || v_xml.getstringval || ']]>');
end;





2) WSO2 DSS

Creacion del Servicio en DSS



Fuente:

<data name="ClientsService" transports="http https local">
<config enableOData="false" id="VATROX">
<property name="carbon_datasource_name">LOCAL_VATROX</property>
</config>
<query id="ClientsInsert" useConfig="VATROX">
<sql>call CLIENTS.INSERT_CLIENT_DSS(:request,:response)</sql>
<result element="Response" rowName="">
<element column="response" name="response" xsdType="string"/>
</result>
<param name="request" sqlType="CLOB"/>
<param name="response" sqlType="CLOB" type="OUT"/>
</query>
<operation name="insertClient">
<call-query href="ClientsInsert">
<with-param name="request" query-param="request"/>
</call-query>
</operation>
</data>


Paso a paso.








Ejemplo de ejecucion.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dat="http://ws.wso2.org/dataservice">
<soapenv:Header/>
<soapenv:Body>
<dat:insertClient>
<dat:request><![CDATA[<C_CLIENT><COLLECTION><O_CLIENT><ID>1</ID><FIRSTNAME>Juan Pablo</FIRSTNAME><LASTNAME>Vadell</LASTNAME></O_CLIENT><O_CLIENT><ID>2</ID><FIRSTNAME>Cesar</FIRSTNAME><LASTNAME>Trono</LASTNAME></O_CLIENT></COLLECTION></C_CLIENT>]]></dat:request>
</dat:insertClient>
</soapenv:Body>
</soapenv:Envelope>

Respuesta:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Response xmlns="http://ws.wso2.org/dataservice">
<response><O_CLIENT_R><RESULT>OK</RESULT></O_CLIENT_R></response>
</Response>
</soapenv:Body>
</soapenv:Envelope>

Monday, January 25, 2016

Using Weblogic JMS as input in Logstash

I am using Logstash 2.1.1.

There is a jms Logstash input plugin at https://github.com/logstash-plugins/logstash-input-jms

Install it:

$LOGSTASH_HOME/bin/plugin install logstash-input-jms

To use it, we need to create a jms.yml configuration file for the plugin.

weblogic:
  :jndi_name: jms/DemoCF
  :jndi_context:
    java.naming.factory.initial: weblogic.jndi.WLInitialContextFactory
    java.naming.provider.url: t3://localhost:7001
    java.naming.factory.url.pkgs: javax.naming:javax.jms
    java.naming.security.principal: weblogic
    java.naming.security.credentials: welcome1
  :require_jars:
    - /Users/jpvadell/oracle/weblogic/12.2.1.0/wlserver/server/lib/wlthint3client.jar
    - /Users/jpvadell/oracle/weblogic/12.2.1.0/wlserver/server/lib/wljmsclient.jar
    - /Users/jpvadell/oracle/weblogic/12.2.1.0/wlserver/server/lib/wlclient.jar

I am using Weblogic 12.2.1 jars connecting to an older Weblogic server without any trouble.

Then we must create the logstash configuration file logstash-wlsjms.conf

input {
  jms {
     use_jms_timestamp => false
     yaml_file => "$LOGSTASH_CONFIG_HOME/conf/jms/jms.yml"
     yaml_section => "weblogic"
     destination => "DemoJMSServer/DemoJMSModule!DemoQ"
  }
}
output {
    elasticsearch { hosts => ["localhost:9200"] }
    stdout { codec => rubydebug }
}

The destination tag is JMSSERVER_NAME/JMS_MODULE!QUEUENAME (not jndi QueueName)

Run it! 

$LOGSTASH_HOME/bin/logstash -f $LOGSTASH_CONFIG_HOME/conf/logstash-wlsjms.conf



Put some messages at the JMS Queue and check it at Kibana.

Enjoy!!

JP

Friday, June 5, 2015

URL to get SOA 11g or SOA 12c Status

If you need to check if SOA is UP and Running there is a URL that you can use from Load Balancers.

http://[host]:[port]/soa-infra/services/isSoaServerReady

It will return response code 503 (Service Unavailable) when SOA Server is not ready to accept requests and 200(OK) when SOA Platform is running and accepting requests.

For 11.1.1.6 and 11.1.1.7 with must apply patch 17571359.



Tuesday, January 27, 2015

JDeveloper 12.1.3 and Apple Mac OS Yosemite Problem

Today I updated Yosemite 10.10.1 to 10.10.2 and JDeveloper couldn't start, just as when updated from Mavericks to Yosemite 10.10.1.

I just removed this directory:


/Users/xxxxx/.jdeveloper/system12.1.3.0.41.140521.1008/system_cache

and starts working again just after some recoverable errors.

Hope this helps.

JP

Friday, December 19, 2014

Publish Event from Java to Oracle SOA 12c EDN

I needed to send EDN Events to a SOA 12c from Java and taking as example the Edwin's Biemond post Publish Event from Java with JMS I decided to update it to version 12c.

In 12c EDN is different, it were rewritten and it's based on Topics.

Now supports WLJMS as default, or you can use AQJMS, and we don't need to specify the Topic, it take it from the default configuration.

Make a new JDeveloper Java Project and create a Java class PublishEvent.


package com.vatrox.soa.edn.utils;

import java.util.Properties;

import javax.naming.Context;

import javax.xml.namespace.QName;

import oracle.fabric.blocks.event.BusinessEventConnection;
import oracle.fabric.blocks.event.BusinessEventConnectionFactory;

import oracle.integration.platform.blocks.event.BusinessEventBuilder;
import oracle.integration.platform.blocks.event.jms2.EdnJmsConnectionFactory;

import oracle.soa.common.util.XMLUtil;

import org.w3c.dom.Element;

public class PublishEvent {
    public static void main(String[] args) {
        // My SOA WebLogic variables
        Properties props = new Properties();
        props.put(Context.PROVIDER_URL, "t3://soaserver.vatrox.com:8001");
        props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
        props.put(Context.SECURITY_PRINCIPAL, "weblogic");
        props.put(Context.SECURITY_CREDENTIALS, "welcome1");
        
        // the business Event
        String DemoEvent = "DemoEvent";
        String NameSpace = "http://xmlns.oracle.com/Vatrox_SOA_EDN/DemoEDN/demoEvent";
        String DemoEventBody =
            "<Evento>" + "<dato>DemoEvent</dato>" + "</Evento>";
        Element eventBody = null;
        try {
            eventBody = XMLUtil.parseDocumentFromXMLString(DemoEventBody.toString()).getDocumentElement();
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            
            BusinessEventConnectionFactory factory = new EdnJmsConnectionFactory(props);
            BusinessEventConnection conn = factory.createBusinessEventConnection();

            // Create an event
            BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
            builder.setEventName(new QName(NameSpace, DemoEvent));
            builder.setBody(eventBody);

            // publish
            conn.publishEvent(builder.createEvent(), 4);
            conn.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


 

The jars that you must use in the project are:
$MDW_HOME/soa/soa/modules/oracle.soa.fabric_11.1.1/edn.jar
$MDW_HOME/soa/soa/modules/oracle.soa.fabric_11.1.1/fabric-runtime.jar
$MDW_HOME/soa/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar
$MDW_HOME/oracle_common/modules/com.oracle.webservices.fabric-common-api_12.1.3.jar
$MDW_HOME/oracle_common/modules/oracle.xdk_12.1.3/xmlparserv2.jar
$MDW_HOME/wlserver/server/lib/weblogic.jar
$MDW_HOME/oracle_common/modules/oracle.jrf_12.1.3/jrf-api.jar
$MDW_HOME/soa/soa/modules/oracle.soa.fabric_11.1.1/tracking-core.jar
$MDW_HOME/soa/soa/modules/oracle.soa.adapter_11.1.1jca-binding-api.jar



 

Thursday, August 28, 2014

java.net.MalformedURLException: Unknown protocol:servicebus or Unknown protocol:bundle - Oracle SOA/BPM Suite 12c

If you are receiving one of this errors trying to use Oracle SOA/OSB/BPM Suite 12c in the same domain you must do this.


1) If you followed the note 12c: Error when Running both BPM and OSB in one Domain, 'java.net.MalformedURLException' (Doc ID 1903573.1) from Oracle Support from some time ago, they change it now.


a) You must take off the felix.service.urlhandlers=false from OSGI Framework start, if you added it before.



b) Now you must add com.bea.wli.sb.resources.url to the setStartupEnv.sh file at your domain/bin directory at every JAVA_OPTIONS where java.protocol.handler.pkgs appears.



setStartupEnv.sh

Change from (20 times maybe)


JAVA_OPTIONS=”${JAVA_OPTIONS} -Djava.protocol.handler.pkgs=oracle.mds.net.protocol|oracle.fabric.common.classloaderurl.handler|oracle.fabric.common.uddiurl.handler
|oracle.bpm.io.fs.protocol

to

JAVA_OPTIONS=”${JAVA_OPTIONS}  -Djava.protocol.handler.pkgs=oracle.mds.net.protocol|oracle.fabric.common.classloaderurl.handler|oracle.fabric.common.uddiurl.handler|oracle.bpm.io.fs.protocol|com.bea.wli.sb.resources.url”




Command in Linux

cp setStartupEnv.sh setStartupEnv.sh.bak


sed ‘s/|oracle.bpm.io.fs.protocol/|oracle.bpm.io.fs.protocol|com.bea.wli.sb.resources.url/g’ setStartupEnv.sh -i


Hope this helps.


Juan Pablo