Thursday, November 21, 2013

The inbound OSB file transport flow explained

The working of the OSB file transport can be explained  as follows:
  • File written to a polling directory
  • Metadata messages posted in internal JMS queue by the file transport and file moved to staging directory
  • OSB Proxy Service triggered by message on the JMS queue
  • Proxy service reads file from staging directory and moves the file to the archive folder when completed
This blogs explains the behavior when you suspend the flow on 3 different places of the flow. In general I think disabling the Proxy Service will be the best alternative in most situations. Anyway, by writing this blog I also hope to increase awareness about the internal working of the file transport in OSB. 

Note: I have tested this all before 11.1.1.7, but I have not read anything that indicates that the behavior should be different between 11.1.1.6 and 11.1.1.7

Action: Disabling the production internal file jms queue

    Error in OSB log:

weblogic.jms.common.IllegalStateException: Destination jmsResources!wlsb.internal.transport.task.queue.file is paused for new message production
        at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:110)
        at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncTran(DispatcherAdapter.java:53)
        at weblogic.jms.client.JMSProducer.toFEProducer(JMSProducer.java:1289)
        at weblogic.jms.client.JMSProducer.deliveryInternal(JMSProducer.java:796)
        at weblogic.jms.client.JMSProducer.sendInternal(JMSProducer.java:541)
        Truncated. see log file for complete stacktrace


  • Message read from the polling directory, but placed in the error directory because of the above error

Action: Disabling the consumption internal file jms queue

  •     Messages read from the polling directory on each poll cycle
  •     Messages moved to the stage directory on each poll cycle
  •     Messages not picked up by the proxy service and remain in the staging directory
  •     After enabling consumption again the stage directory was immediately emptied and messages eventually ended up in the archive folder

Action: Disabling proxy service


    The following error can be seen when the proxy is disabled during a poll cycle execution:

#### <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <88685c90d4ac9d24:-768bd09e:1392b67272a:-8000-000000000000029f> <1345055025030>  javax.ejb.EJBException: nested exception is: com.bea.wli.sb.transports.TransportException: ProxyService default/PS_FILE_INBOUND has been disabled.
javax.ejb.EJBException: nested exception is: com.bea.wli.sb.transports.TransportException: ProxyService default/PS_FILE_INBOUND has been disabled
        at com.bea.wli.sb.transports.poller.listener.PolledMessageListenerMDB.__onMessage(PolledMessageListenerMDB.java:55)
        at com.bea.wli.sb.transports.poller.listener.PolledMessageListenerMDB.access$000(PolledMessageListenerMDB.java:31)
        at com.bea.wli.sb.transports.poller.listener.PolledMessageListenerMDB$1.run(PolledMessageListenerMDB.java:41)
        at com.bea.wli.sb.transports.poller.listener.PolledMessageListenerMDB$1.run(PolledMessageListenerMDB.java:39)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.security.Security.runAs(Security.java:41)
        at com.bea.wli.sb.transports.poller.listener.PolledMessageListenerMDB.onMessage(PolledMessageListenerMDB.java:39)
        at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:583)
        at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:486)
        at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:388)
        at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4659)
        at weblogic.jms.client.JMSSession.execute(JMSSession.java:4345)
        at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3821)
        at weblogic.jms.client.JMSSession.access$000(JMSSession.java:115)
        at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5170)
        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

  • The error above ONLY occurs when messages are picked up from the polling directory and in-flight when the PS is disabled. All 10 messages of that poll cycle are moved to the error directory. From here they can be recovered
  •  No messages are picked up from the polling directory after the PS is disabled

Sunday, June 13, 2010

OSB 11g - JCA polling adapter: StuckThread trace in the server log

I recently had to configure in OSB 11g the JCA AQ adapter to poll for new messages on an AQ inbound queue. This is quite easy using this tutorial.

However after I had configured the adapter and run some successful tests I saw the following stack trace in the server log after a period:


<[STUCK] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "600" seconds working on the request "weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl@4b936059", which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:129)
oracle.net.nt.MetricsEnabledInputStream.read(TcpNTAdapter.java:564)
oracle.net.ns.Packet.receive(Packet.java:295)
oracle.net.ns.DataPacket.receive(DataPacket.java:94)
oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:176)
oracle.net.ns.NetInputStream.read(NetInputStream.java:121)
oracle.net.ns.NetInputStream.read(NetInputStream.java:96)
oracle.net.ns.NetInputStream.read(NetInputStream.java:81)
oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:124)
oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:80)
oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1087)
oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1062)
oracle.jdbc.driver.T4Caqdq.receive(T4Caqdq.java:338)
oracle.jdbc.driver.T4CConnection.doDequeue(T4CConnection.java:4067)
oracle.jdbc.driver.PhysicalConnection.dequeue(PhysicalConnection.java:16057)
oracle.jdbc.driver.PhysicalConnection.dequeue(PhysicalConnection.java:16138)
oracle.jdbc.OracleConnectionWrapper.dequeue(OracleConnectionWrapper.java:1594)
weblogic.jdbc.wrapper.XAConnection_oracle_jdbc_driver_LogicalConnection.dequeue(Unknown Source)
weblogic.jdbc.wrapper.JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection.dequeue(Unknown Source)
oracle.tip.adapter.aq.v2.database.AbstractDequeueAgent.dequeue(AbstractDequeueAgent.java:356)
oracle.tip.adapter.aq.v2.database.AbstractDequeueAgent.dequeueMessage(AbstractDequeueAgent.java:259)
oracle.tip.adapter.aq.v2.database.AbstractDequeueAgent.getInputRecord(AbstractDequeueAgent.java:232)
oracle.tip.adapter.aq.v2.database.AbstractDequeueAgent.run(AbstractDequeueAgent.java:101)
weblogic.work.ContextWrap.run(ContextWrap.java:41)
weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
weblogic.work.ExecuteThread.run(ExecuteThread.java:173)



Apparently, this StuckThread trace occurs 10 minutes after the server has been started and is caused by the fact that WebLogic uses by default 1 polling thread which remains active, or in other words is never released by the adapter, by design. Therefore the stuck thread trace can be ignored.

Please look in the OSB JCA transport guide for a detailed explanation and the configuration steps that can be applied to prevent stuck thread traces for polling threads (use a special configured Workmanager)

Wednesday, June 02, 2010

Coherence in Oracle Fusion Middleware 11g: useful tips & links

Since the release of Oracle Fusion Middleware 11g the integration of Coherence in the Fusion Middleware has increased drastically with every PatchSet release. Currently in FMW 11g PS2 Coherence is used for:

  • Cluster Deployment

  • Weblogic ActiveCache/Coherence*Web integration

  • OSB ResultCache


This posting will contain useful pointers to documentation section that can help you with managing and using Coherence in FMW 11g...the list is not complete but a first attempt to bundle the links I have used before and which were/are very helpful for me.
Coherence Network and performance tuning

  • Configuration tips fo local laptop configuration - Thanks Marc;

  • use the tangosol.coherence.ttl (time-to-live) to prevent network traffic to different hosts - useful when working locally on laptops.

  • use the tangosol.coherence.localhost to force Coherence to bind to a specific address

  • use the tangosol.coherence.wka to force unicast cluster communication. Determine the wka addresses and the number of wka addresses carefully to avoid loss of service in case the wka nodes die.

  • for the OSB the coherence cache and cluster configuration files can be found in /config/osb/coherence
  • and can be changed accordingly.
  • When encountering Coherence socket buffer warnings in the log files it is useful to increase the socket buffer size of your OS. Please have a look here to find the settings per OS

  • Coherence performance tuning

  • In my opinion it is wise not to use the Managed server JVM for cache storage in case your cache will grow to a significant size. Configure the Managed Server JVM with local-storage false and off-load storage to other cache-servers in the Coherence cluster running in separate JVMs


Active Cache - Coherence*Web

I will update this post when I have more useful information that can be shared. In case of Coherence related questions feel free to send me an email.

Sunday, May 30, 2010

Book review: Oracle Coherence 3.5: Create internet scale applications using Oracle's high-performance data grid

The IT book publisher PackT asked me, based on my blog activities here, a couple of weeks ago if I was willing to review the newly published book Coherence 3.5. Being a person who works with Coherence, follows the developments around Coherence and believes in the capabilities of Oracle Coherence for building reliable scalable architectures, I was definitely willing to review this book and to bundle my feedback in a blog posting afterwards.

The book starts with an overview of what scalability, performance and high availability means and (also important) what not, what it does involve, how you achieve it and how Coherence fits into this picture. After explaining the basic concepts of performance, scalability and availability the book proceeds with explaining how easy it is to start off with Oracle Coherence to build your first 'Hello World' Coherence application.

After this overviev the book starts with the 'real stuff'. First a detailed overview is given about the different type of caching topologies and the options Coherence provide to decide for the right caching strategy. The book also provides so called 'When to use it?' chapter per topology in which it explains for which typical applications the topolgy is applicable and should be used; very useful. The following chapter explains how you can define your domain objects and make them Coherence-aware. In this chapter it uses the concepts of Domain Driven Design as the basis to construct the domain model for a sample applications. For me personally, this chapter was an eye-opener regarding building domain models for Coherence. One thing you should keep in mind, which i had learned before, when you start using Coherence is that you should keep things very simple and don't treat Coherence as an in-memory relational database. only put those things in Coherence grid which should be in the cache and avoid to think like you're going to build a database relation model. For example, store whole aggregates (Order, order items) in a single cache entry for the sake of atomicity, consistency and simplicity. The chapter also provides information about efficient object serialization using Coherence Portable Object Format (POF) and object change managements using evolvable objects.

The book continues with covering the following topics that makes the book a complete Coherence
reference :

  • Querying the Grid

  • Entry processing

  • Event processing

  • Persistency

  • Coherence*Extend

  • C++ and .Net interoperability




My final conclusion about this book is that is an excellent book to start off with in order to make yourself familiar with implementing Coherence applications. The book is complete in terms of
'should-know' features and contains useful guidelines and best-practices.

The book can be ordered from here:
- PackT site
- Amazon site

Friday, May 07, 2010

How-to: Analyzing Out-Of-Memory issues in WebLogic 10.3.3 with JRockit 4.0 Flight Recorder

Oracle WebLogic Server 10.3.3 provides out-of-the box support for JRockit Flight Recorder (JFR); the new enhanced run-time JVM analyzer in JRockit 4.0 positioned as the replacement for JRA with the following points of improvement Always on, Better data, third-party application integration through an API and low-to-zero overhead. JFR integrates seamlessly with WLS 10.3.3 to produce recording images on demand or event-based to analyze and solve all kinds of JVM issues.

In this blog posting, I show how to capture automatically an overall WLS system image, including a JFR image, after an out-of-memory (OOM) exception has occured in the JVM hosting WLS 10.3.3.

Setting up WLS Diagnostic framework
To enable event generation by WLS for JFR, the Weblogic Diagnostic Volume property has to be set to the value low, medium or high indicating the amount of recorded events. The
Diagnostic Volume can be set in the WLS Administration console -> Environment -> servers -> YourServer.



Now we have started event generation by WLS for JFR, we have to configure a WLS Diagnostic system module with a watch rule and a notification so that image capturing is triggered whenever an OOM error happens. The image capturing mechanism captures the WLS system state together with the JFR buffered event data and generates a zip file in containing the JFR file in the image folder. The image folder is specified in the WLS adminstation console -> Diagnostics -> Diagnostic images -> YourServer



Go in the WLS Administration console to WLS adminstation console -> Diagnostics -> Diagnostic modules and create a new diagnostic module. I have called it JRFDiagnosticeModule. Click on the created diagnostic module and target it to the designated server (tab Targets). Go back to configuration tab and click on the Watches and Notifications tab to create a watch rule and a notification with following specs:

Watch rule

  • Type = Server Log

  • Expression = (MESSAGE LIKE '%OutOfMemoryError%')

  • Use an automatic alarm so that the rule is re-enabled each time it is triggered after a defined period


Notification

  • Type = Diagnostic Image



Make sure everything is enabled and the notification is associated with the watch. Leave every other setting to their defaults.

This is all we have to do in WLS 10.3.3. Before we proceed with triggering a OOM with a sample application, we first start the JRockit Mission Control (JRMC) application to verify that the JFR recording has been started. Execute the jrmc file in the folder /bin folder to start JRMC. Open the JVM browser and right-click on the WLS jvm and select view reports. In the lower-right panel you'll see that one recording has been started:



Generate an OOM error
To generate an OOM I've created a simple web application constisting of a simple page with a button that triggers a servlet that will execute the following code-snippet to generate an OOM in WLS 10.3.3.


List list = new ArrayList();
while(true){
list.add("test string");


Deploy the web application to the WLS server and trigger the OOM by pressing the button on the page. After a few seconds you'll see this in console logging:



The console logging shows that the watch rule has been triggered and a image capture has been generated in the folder /servers/AdminServer/logs/diagnostic_image. Unzip the file and open the JRockitFlightRecorder.jfr file in JRMC.

In the JRMC console you are now able to analyze the root cause of the problem. For this obvious OO example (you can also get the root cause from the console output..but the intention here is to show the capabilities of JFR in general), you can have a look at the allocation tab in the Memory panel to drill down to class that causes the String object creation (It's just an example and the JFR contains a lot more information about Threads/CPU utilization and GC executions for example):




Also the Hot Method tab in the Code panel shows the servlet doPost method as a top listed hot method:



This simple and obvious example shows how easy it is to let WLS diagnostic framework continuously produce monitoring data for JFR that can be dumped to a JFR image when required, e.g. in case of OOM exception or other events. The default WLS diagnostic framework can be configured to collect a specific amount of events by using the coarse-grained Diagnostic Volume property. If you want extra events to JFR image you can start extra Recording by using the JRMC or using the command line. Also it is possible to use Java startup parameter -XX:+|-FlightRecordingDumpOnUnhandledException to trigger a JFR dump after a unhandled exception in the JVM.

Documentation:

Thursday, May 06, 2010

How-to: Building REST/JSON services with OSB 11g and JAX-RS

Last couple of weeks, I have read a lot of blog postings about REST services in combination with the Oracle Service Bus (like this posting). I've even made a first attempt to write a posting about this subject, but I got really constructive comments in return on that posting that I decided to write a complete new one. Thanks for the comments :)

I decided to play around with REST and OSB myself and choosed for JAX-RS (Jersey) as the Java technology to build my REST service and the brand new OSB 11g release for proxing this REST service. In this posting, I will show you how easy it is to build a REST/JSON service with the feature rich and highly flexible JAX-RS standard, deploy it to WebLogic 10.3.3 and proxy it with an OSB 11g service.

REST service in JAX-RS
Required libraries (can be downloaded from here):

  • jersey-bundle-1.1.5.1.jar

  • jsr113-api-1.1.jar

  • asm-3.1.jar


I build in JDeveloper a very simple REST product service with a single method to find a product by its id. The REST method returns a JSON representation of the product.

First you have to create a new web application project in JDeveloper, because the JAX-RS product service is deployed as a web application to the WebLogic Server. In the web.xml file the following things has to be specified:

  • the JAX-RS servlet which will handle all requests and forward them to the appropriate REST Service class.

  • The context path to access the servlet

  • The mime type application/json


The web.xml has the following content:



xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
web.xml for

10


html
text/html


json
application/json


txt
text/plain


JAX-RS Servlet
jersey-servlet
com.sun.jersey.spi.container.servlet.ServletContainer

com.sun.jersey.config.property.resourceConfigClass
com.sun.jersey.api.core.PackagesResourceConfig


com.sun.jersey.config.property.packages
nl.oracle.com.fmw.rest;nl.oracle.com.fmw.rest.model



jersey-servlet
/*



Now the web.xml file is in place, two Java classes have to be implemented:

  • ProductResource

  • Product


The ProductResource class will contain the method to find a product by its id:

package nl.oracle.com.fmw.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import nl.oracle.com.fmw.rest.model.Product;

@Path("/products")
public class ProductResource {

@GET
@Path("{id}")
@Produces("application/json")
public Product getProductById(@PathParam("id") int id){
//Return a simple new product with the provided id
return new Product(id, "DummyProduct");
}
}


The code listing above shows that that getProductById method is only accessible through the HTTP GET method. Also the use of the @Path annotation on the class and method level makes it possible to set a specific relative-uri with which the service can be accessed. The {id} serves as a placeholder for the product id and can be accessed through @PathParam annotation

The Product class is shown in the following code listing and uses the JAXB XmlRootElement binding annotation to automatically map the class structure to a JSON structure. Isn't that cool :). More JSON serialization and deserialization options in JAX-RS can be found here

package nl.oracle.com.fmw.rest.model;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Product {

private int id;
private String name;

public Product(){

}

public Product(int id, String name) {
this.id=id;
this.name=name;
}

public void setId(int id) {
this.id = id;
}

public int getId() {
return id;
}

public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}
}

Coding is completed and it should be clear now that the use of annotations makes it very easy and flexible to create REST services with JAX-RS. Create a WAR deployment descriptor and make sure you add the jersey libraries to the WAR file and set the JEE web context root to services. Finally, deploy the WAR file to the WebLogic 10.3.3 server. I target the application to the osb_server1 managed server, which hosts my OSB 11g installation.

After deployment you can test the REST service using this URL where I use 1 as the id:

http://localhost:port/services/products/1


OSB 11g proxy
I used the brand new OSB 11g installation for creating a proxy service for my REST service.

The implementation is fairly simple and straight forward and follows more or less the same steps used in this excellent posting:

Business Service
The business service invokes the REST product service. Make sure you use the messaging service type with the HTTP transport protocol. Also set the HTTP method to GET.

Proxy Service
Create a proxy service in Eclipse and use the messaging service type with the HTTP transport protocol. I used request type none and Response type text. In the message flow I added a routing action to invoke the business service.
I need to mention two important things about the my Proxy service implementation

  • Set the endpoint /osb-services/products. This enables you to add anything to this context path, for example /{id}. This makes it also possible to use the OSB service as a proxy for different types of REST calls (make sure you can switch between HTTP methods in the message flow) to the same product service

  • Use the transport request element from the $inbound variable to append the relative path after /osb-services/products to the REST service endpoint. I've used an insert operation for this:





Deploy the OSB service to the OSB 11g server and use the test console to test the service. Make sure you set the relative-uri attribute in the test console transport panel:



The $body element in the response message should look like this:



The OSB service just passes the JSON response forward to the client. It is fairly simple to convert the JSON output to XML and vice versa using JSON lib in a Java service callout. How to do this is described in this posting.

Also the JSON structure returned by the product service is very simple. In most cases you have to do more work with JAX-RS in order to construct the required JSON structure. The JAX-RS libraries contain options for configuring JSON

Sunday, March 07, 2010

How-to: Oracle Service Bus 10gR3 - Oracle FMW B2B 11g interoperability

In this posting I will describe how you can integrate Oracle B2B 11g and Oracle Service Bus 10gR3 to send messages to Oracle B2B 11g from an OSB 10gR3 service.

The most easy way to integrate Oracle B2B 11g and OSB 10gR3 is by using JMS. Oracle B2B 11g supports JMS as protocol for its internal inbound and outbound delivery channels out-of-the-box.To enable JMS set the Use JMS Queue as default property to true in the Administration -> Configuration tab in the Oracle B2B 11g management console in order to switch on the usage of the JMS queues B2B_IN_QUEUE and B2B_OUT_QUEUE.

I have reused the ebXML configuration that I have described in a previous blog posting in this example. In Oracle Workshop 10gR3 (shipped with OSB 10gR3) you now have to make a simple OSB service that accepts a message through a proxy service and enqueues the message on the B2B_OUT_QUEUE of Oracle B2B 11g using a business service. Below I will describe the details that require special attention while implementing the OSB 10gR3 service.

Business Service - JNDI string
The BS serves as a JMS wrapper for the B2B_OUT_QUEUE. Use the following JNDI string to locate the
ConnectionFactory and Destination:


jms://(ofm b2b 11g host):(port)/jms.b2b.B2BQueueConnectionFactory/jms.b2b.B2B_OUT_QUEUE


Proxy Service - message flow
Oracle B2B 11g expects several user header properties in the JMS transport header to be set. A list of the required properties can be found here. You have to use the property names defined in the second column. To set the user header properties use the Transport Header action in the request lane of the Routing action (assumed you use a Routing action). Click on Add Header to add a new header property and select Other to define a custom header property. Add header properties for all listed properties in the table expect the last four in the table (at least I didn't set them)

Here's a screen shot of my OSB 10gR3 configuration:



After you have completed the message flow publish your configuration to the server and use the SB console test functionality to execute a test.

Wednesday, February 17, 2010

How-to: Archiving Oracle FMW B2B 11g run-time data using data pumps

In Oracle Fusion Middleware B2B 11g enhanced procedures are introduced to archive and/or purge the B2B 11g run-time data.

The procedures that take care of archiving/purging live in the SOAINFRA database schema of your FMW 11g database repository:
  • B2B_ARCHIVE_PROCEDURE
  • B2B_EXPORT_JOB

The B2B_EXPORT_JOB procedure does the actual archiving and is invoked from the B2B_ARCHIVE_PROCEDURE procedure. The B2B_EXPORT_JOB procedure uses a data pump to archive the run-time data to a file on the file system.

To make use of data pumps, you first have to grant SOAINFRA with DIRECTORY object privileges in order to allow SOAINFRA to create a DIRECTORY object that points to the location on the file system in which the data pump will write the archive file (the name of the DIRECTORY object should be B2B_EXPORT_DIR):

-- I tested it on my development installation using XE, hence the 'dev' prefix
GRANT create any directory TO dev_soainfra;
GRANT drop any directory TO dev_soainfra;

after granting the right priviliges you can create the directory object with:

create or replace directory "B2B_EXPORT_DIR" as '(absolute patch to the location on the file system)'

The following script will archive and purge all the run-time data for completed messages from 19-02-2009 until 19-02-2010 and will archive the data in the file called 'b2b_runtime_export.dat':

begin
b2b_archive_procedure(to_date('19-02-2009', 'dd-mm-yyyy'),to_date('19-02-2010', 'dd-mm-yyyy'),'MSG_COMPLETE','b2b_runtime_export.dat','Y');
end;

The standard archiving script provided by Oracle FMW B2B 11g can easily be extended to fit your specific needs or to be merged into existing archiving procedures.

References:
- Oracle FMW 11g documentation

Monday, January 25, 2010

Book review: Middleware Management with Oracle Enterprise Manager Grid Control 10g R5

In December last year the publisher of IT books Packt Publishing contacted me to ask me if I was willing to read their newly released book about Oracle Enterprise Manager Grid Control:

Middleware Management with Oracle Enterprise Manager Grid Control 10g R5

They've selected me based on the contents of my blog.

The book is well structured and written in a clear language. The book starts with explaining the main features of Oracle Enterprise Manager Grid Control and how they address common administration tasks and make the life of a system administrator easier. The book continues with defining and describing the main components of Oracle Enterprise Manager Grid Control and how they work together to enable Oracle Enterprise Manager Grid Controll to fulfill its tasks. In the subsequent chapters the book covers the main Oracle middleware components and explains how they can be managed with Oracle Enterprise Manager Grid Control. The following components caught my specific attention:

  • Oracle BPEL Process Managers
  • Oracle Service Bus
  • Oracle Weblogic Server
  • Oracle Coherence

Each chapter contains detailed information about how to configure and use specific Oracle Enterprise Manager Grid Control features, like notification management, automatic provisioning and managing configuration inconsistencies. Additionaly the book cover topics like CAMM, AD4J and how to write your own monitoring plug-in.The book concludes with a best practice chapter.

To be honest, system administration is not my main focus area. I'm more on the software development side..Therefore my main intention to read this book (Oh..I agreed to review this book..) was to learn more about the concepts, capabilities and benefits of using Oracle Enterprise Manager Grid Control to manage the Middleware layer to broaden my view on middleware management (the area in which I mainly develop software). After reading the book, I can only conclude that this book really has helped me to understand the the true capabilities and benefits of Oracle Enterprise Manager Grid Control and how it can be used to manage Oracle Middleware components. This book is really a good starting point for everyone who wants to learn more about Middleware Management with Oracle Enterprise Manager Grid Control

You can find more info about the book and how to order it on the book's homepage

Wednesday, January 13, 2010

How to: OSB - FMW SCA 11g interoperability supporting transaction propagation

Currently, the BPEL transport in OSB is not supporting FMW 11g. However, I just found a way, although it still is proven in theory based on my knowledge, to enable transaction propagation between OSB and FMW 11g SCA composites. The basic idea is that you have to communicate between OSB and FMW 11g SCA composites using the SDO - EJB binding in 11g. The t3 protocol used as the communication protocol between the ejb client and the SCA (soa_infra) engine should take care of the transaction context propagation.

This should do the trick until OSB gets native support for FMW 11g interoperability. One disclaimer; I still have to prove my theory by running a test, but I am quite sure that it will work so therefore I shared it already here. I also still have to elaborate on which MEPs could be supported with this solution, so any thoughts are welcome.

Sunday, January 10, 2010

Oracle FMW B2B 11g: How to collect HTTP header info from inbound messages using Java Callouts

In Oracle FMW B2B 11g the Java callout functionality makes it possible to add Java hooks to an inbound or oubound message flow. Callouts van be written and configured per agreement or per delivery channel (transport callouts). More info about managing callouts can be found here

In this blog posting, I will show how you how an agreement callout can be used to collect HTTP headers from an inbound message, which is received by the default B2B transportServlet. I use an agreement callout because it is not possible to define a transport callout for an inbound http host channel.

The callout implementation is rather simple:
package nl.oracle.com.b2bcallout;

import oracle.tip.b2b.callout.Callout;
import oracle.tip.b2b.callout.CalloutContext;
import oracle.tip.b2b.callout.CalloutMessage;
import oracle.tip.b2b.callout.exception.CalloutDomainException;
import oracle.tip.b2b.callout.exception.CalloutSystemException;


public class HttpHeaderAgrCallout implements Callout {

    public void execute(CalloutContext arg0, List input,
                        List output) throws CalloutDomainException,
                                            CalloutSystemException {
        try {
            CalloutMessage cm1 = (CalloutMessage)input.get(0);
            
            
            System.out.println("parameters - "+cm1.getParameters().toString());
            
            CalloutMessage cmOut = null;
            String msg = cm1.getBodyAsString();

            String headerStr = cm1.getParameters().toString();
            System.out.println("Print transport header ::");
            System.out.println(headerStr);
            

            cmOut = new CalloutMessage(msg);
            output.add(cmOut);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
The getParameters() methods returns all the HTTP transport header attributes in a Properties object.

Compile the callout code and deploy it to a jar file. The jar file has to be copied a location that can be accessed by the B2B server (or all B2B nodes if you have a clustered environment). Have a look at the B2B callout documentation to find out how you configure the callout with your inbound agreement.

It is wise to put Agr or Transport in the callout name to make a clear distinction between the types of callouts as they appear together in the callout selection drop down list in the B2B management console.

So why do you need this anyway..well for example to extract a specific HTTP header attribute that is, for example, set by the front-end HTTP Server and enrich the message with it.

Friday, December 18, 2009

Some Tips on Oracle FMW 11g Clustering: deployment and configuration

In this blog-posting, I share some first tips on Oracle FMW 11g (11.1.1.2/PS1) cluster-wide deployment and cluster configuration based on my first experiences with setting up such an environment.

Most tips come from these two documents:
- Enterprise Deployment Guide for Oracle SOA Suite
- Oracle FMW 11g High-Availability Guide


Cluster-wide deployment tips
  • More info on SCA deployment with Ant can be found through my previous posting
  • Deploy a composite to a specific node of the cluster: the deployment coordinator in the Oracle FMW 11g cluster infrastucture will take care of the correct propagation to all the other nodes or rollback in case of a failure on a specific node. For more info on this have a look here.
  • Set up Oracle Coherence for unicast communication during cluster-wide deployments. Have a look here for more details.

Configuration tips
  • Make sure you set the value of the serverURL and the callbackServerURL to the front-end SOA cluster location. In most cases this will be the endpint of the front-end loadbalancer. If you have set the SOA Cluster Front-End URL in the Oracle Weblogic Server Administration Console (location: Clusters -> ) its value will be used for the serverURL and callbackServerURL.
    Note: For unclear reasons, I solved cluster-wide deployment problems by setting the server- and callbackServerURL.
  • You can apply configuration changes to any specific node in the Oracle FMW 11g SOA cluster. Oracle WebLogic Clusters takes care of automatic configuration synchronization across all the nodes of the cluster.

I hope to share more tips here in the near future.

Monday, December 07, 2009

Oracle Fusion Middleware 11g purge scripts available on Oracle Metalink

On Oracle Metalink there is now a Note available that describes the usage of the FMW 11g purge scripts. Note 815896.1 contains all the details.

An OPatch patch 8328187 is available for download that contains all the scripts that are required to create the purging functionality in the SOA_INFRA schema

How to set-up a common Ant project for using the Oracle FMW 11g B2B Ant tasks

Inspired by this great blog posting about how to use the FMW Ant tasks to deploy a SOA composite, I started to use that example to set up my own Ant project for B2B management purposes.

In this blog-posting, I will give an example project that is capable of importing and exporting CPAs to and from Oracle FMW 11g B2B.

Setup the build project
In JDeveloper, create an empty project and name it fmw-build for example. Create the following *.properties
  • env.properties
  • dev.jndi.properties
  • dev.cpacpp.properties
Also, import the ant-b2b-util.xml and the ant-soa-common.xml files that are located in JDEV_HOME\bin folder.

The b2bmanagement.properties files contains all the enviroment specific properties and I used the following contents:


deployment.plan.environment=dev

#dev deployment server weblogic
dev.serverURL=http://localhost:8001
dev.overwrite=true
dev.user=weblogic
dev.password=welcome1
dev.forceDefault=true


# global
wn.bea.home=/home/tomhofte/oracle/fmw11gr2
oracle_home=${wn.bea.home}/Oracle_SOA1
java.passed.home=/home/tomhofte/java/jdk1.6.0_17
wl_home=${wn.bea.home}/wlserver_10.3

libs=/home/tomhofte/libs
path.to.antcontrib.lib=${libs}/ant-contrib/ant-contrib-1.0b3.jar


dev.JAVA_HOME=/home/tomhofte/java/jdk1.6.0_17
#Empty home is enough to let it work
dev.ANT_HOME=


The dev.jndi.properties file contains the jndi properties of my local development environment. I used the following contents:


java.naming.provider.url=t3://localhost:8001
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.security.principal=weblogic
java.naming.security.credentials=welcome1


The dev.cpacpp.properties contains the cpa/cpp import/export properties for my local development environment. Please have a look here for more information about this part. Please note that for importing exporting a CPA you first have to export the design repository and specify the resulting zip file as the input for the CPA/CPP export utility. The contents I used are:


# CPP/A Output files
oracle.tip.b2b.ebms.OutputFolder=b2b-tmp/output/

# Oracle B2B Metadata File in case of CPA Export
oracle.tip.b2b.ebms.Document=b2b-tmp/output/Paris.zip

# ebXML CPA File incase of CPA Import
#oracle.tip.b2b.ebms.Document=/tmp/input/cpa-example-2_0.xml


# Host Name
oracle.tip.b2b.ebms.Host=Berlin
# Host endPoint Details
oracle.tip.b2b.ebms.HostEndPoint=http://localhost:8001/b2b/transportServlet
# Host Certificate Alias
oracle.tip.b2b.ebms.HostCertificateAlias=Berlin
# Trading Partner Certificate Alias
oracle.tip.b2b.ebms.TPCertificateAlias=Paris
# BPSS Export
oracle.tip.b2b.ebms.BPSSExport=false

#Log config
oracle.tip.b2b.ebms.LogFolder=b2b-tmp/output/log/
# DEBUG|INFO|ERROR
oracle.tip.b2b.ebms.LogLevel=DEBUG
# text|xml
oracle.tip.b2b.ebms.LogType=text


Now that all required property files are in place, I use an Ant wrapper script to call the tasks in the ant-b2b-util.xml file and provide the necessary properties. Just as is done in this posting. Here are the contents of my b2b-management.xml file:

(Note: for layout purposes I had to use explicit XML end tags..:()






























Note: In the ant-b2b-util.xml I had to replace the oracle.home property with a oracle_home named property to be able to use my own oracle home property. At least, this is the case when I execute the script from JDeveloper 11g. Apparently, the oracle.home property file is predefined by JDeveloper, because I get an "Override ignored" message.. I think it won't matter when you execute the script from the command line..

More info about the usage of the tasks defined in the ant-b2b-util.xml can be found here:

http://download.oracle.com/docs/cd/E15523_01/integration.1111/e10229/scrpt_imp_exp_dep.htm#CEGBDIDB

Wednesday, November 25, 2009

How to change BPEL 11g preference values during deployment time

How you can set BPEL preferences in 11g during design time in JDeveloper and run-time in the EM console is described here (for the latter look in the comments for a reference).

Sometimes it is useful to change the preference values during deployment time, because preferences hold environment specific values. Actually, this is pretty easy by using composite deployment configuration plan(s). One for each target environment.

Right-click on the composite file and generate a deployment configuration plan for your composite. When you open the file, you will find a search/replace construction for the preference.



someValue




Now change the value to the environment specific value, save the config plan and use the config plan during deployment to a specifc environment.

Monday, November 23, 2009

Oracle Fusion Middleware 11g end-to-end tracking using the ECID

In a previous posting I described how you could use composite sensors to enable end-to-end tracking for messages that move through the Oracle Fusion Middleware SCA engine and the B2B engine.

Today, I discovered that you can also use ECID for end-to-end tracking. The B2B application message contains all the tracking properties that are originated from the SCA composite that submitted the message to the B2B engine. With the B2B Report console you are able to search for messages using the ECID. To enable searching on ECID, you have to add the ECID search field to the search panel (use the Add fields button ):




So, the ECID also enables end-to-end message tracking in Oracle Fusion Middleware 11g when message move through the B2B engine. This time completely out-of-the-box.

UPDATE 25-11-2O09: The application message holds the fabric data for in and outbound message from the SCA FMW11g fabric [OLD Disclaimer: I only tested it for outbound communication using the native B2B adapter. Still have to test it for inbound communication and AQ and JMS interfacing with the B2B engine.]

How to configure an ebXML communication in Oracle Fusion Middleware B2B 11g

Oracle Fusion Middleware (OFM) B2B 11g supports many business document and messaging standards. ebXML (Electronic Business using Extensible Markup Language is a B2B messaging standard that is also supported by OFM B2B 11g. Shortly described ebXML enables XML messaging over the Electronic Business messaging Service (basically a SOAP extension), abbreviated as ebMS.

This posting describes how to set-up ebXML messaging using two local OFM B2B 11g (PS1) domains. For simplicity, I will extend my previous B2B example.

Please refer to my previous postings for more info about specific B2B 11g configuration concepts:

- http://tomhofte.blogspot.com/2009/10/how-to-set-up-xml-document-exchange.html

- http://tomhofte.blogspot.com/2009/10/easy-binding-of-oracle-fusion.html

Note
You have to configure both Paris and Berlin. Both configurations are mirrored. Normally, you would use the CPA/CPP import functionality of OFM B2B 11g for this. Unfortunately, I don't have a CPA availabe for this simple demo.

Trading Partners
Configure the hosts and TP in both B2B installations:
  • Paris (receiving role)
  • Berlin (sending role)
(Just use all the defaults, including the TP identification type 'Name')

Configure the document
An ebXML document is defined as a Custom document protocol in OFM B2B 11g. For simplicity, I have used my previous Order document example. I only have to change the document type and definition to resp. configure the ebMS specific properties
  • Action
  • Service
  • ServiceType
  • From role
  • To role

and to configure the inbound document identification. I used the XPATH Identification Expression for identifying inbound documents. Also specify a document routing id in the routing tab (I used Berlin_Order). The routing id can be used to route inbound messages to specific applications.


Delivery Channels
For both Berlin and Paris, I have specified Delivery Channels that uses the ebMS 2.0 protocol (I could use ebMS 1.0..but I prefer newest versions :)). Configuring an ebMS 2.0 delivery channel requires some specific settings. Here are the transport protocol settings that I have used:

  • url: http://host:port/b2b/transportServlet for receiving messages over http
  • Ack mode: async
  • Response mode: none
  • Retry count: 4
  • Retry interval: 2
  • -- Leave all the other setting to their default
Deployment and testing
Deploy the agreements (make sure you configure the capabilities correctly: Berlin is the sender and Paris the receiver in this scenario) on both sides (look here how to configure capabilities and agreements). To test the ebXML configuration, I have used my previous SCA example and modified it for this example. The modifications are in the mediator component, because I have to specify extra B2B adapter properties to allow the B2B engine to identify the agreement. For outbound communication there are two ways to identify an agreement using the B2B adapter in a OFM composite:

1. To and From party + document type and revision. B2B properties:
- b2b.documentTypeName
- b2b.documentProtocolRevision
- b2b.fromTradingPartnerId
- b2b.toTradingPartnerId

2. To and From party + ebMS Action, Service and Service Type:
- b2b.ebms.Service*
- b2b.ebms.ServiceType*
- b2b.ebms.action*
- b2b.fromTradingPartnerId
- b2b.toTradingPartnerId

(*) Those properties are not defined in the JDeveloper Assign activity wizard. You have to manually type in the names in the property selection panel

I used the second option with the following values:
  • action = Order_Action
  • Service = Order_Service
  • Service Type = Order_Service_Type
  • To party = Paris
  • From party = Berlin
Deploy the SCA composite and use the Test functionality of the EM console to run a test case. You can see the exact ebMS message when you click the packed message link in the wire message details screen.

Saturday, November 14, 2009

Installing Oracle Fusion Middleware 11.1.1.2: Tips based on my experience with installing on Kubuntu 9.10

I have installed Oracle Fusion Middleware 11.1.1.2 on my local Kubuntu 9.10 (64bit). This posting contains some tips based on my experience.

Please have a look here to find more details about where to find the new Oracle Fusion Middleware Release.

To install the new release you have to upgrade WLS to 10.3.2 and install the new SOA component again. I decided to throw everything away, download the complete new release including the new RCU and JDeveloper release (don't forget this component!) and install everything again..

Required software:
- Weblogic Server 10.3.2 generic (I have a 64 bit config)
- JDeveloper 11.1.1.2
- SOA Suite 11.1.1.2
- RCU (See additional software section)

Please follow the installation instructions, which can be found here, to install the components in the correct order.

JDK issues
With my default OpenJDK version (build#16) I encountered problems with the WLS installer and with starting the installer of the SOA Suite component.

The WLS installer only started in console mode:

tomhofte@tomhofte-laptop:~/downloads$ java -jar wls1032_generic.jar
Unable to instantiate GUI, defaulting to console mode.
Extracting 0%....................................................................................................100%

<-------------------- Oracle Installer - WebLogic 10.3.2.0 ------------------->

Welcome:
--------

This installer will guide you through the installation of WebLogic 10.3.2.0.
Type "Next" or enter to proceed to the next prompt. If you want to change data entered previously, type "Previous". You may quit the installer at any time by typing "Exit".

Enter [Exit][Next]>

<-------------------- Oracle Installer - WebLogic 10.3.2.0 ------------------->


Not really convenient...

When I tried to start the SOA Suite installer using my OpenJDK as the java runtime the following problem showed up in the console and the installer UI did not show up.

Starting Oracle Universal Installer...


Checking if CPU speed is above 300 MHz. Actual 800 MHz Passed
Checking Temp space: must be greater than 150 MB. Actual 47087 MB Passed
Checking swap space: must be greater than 500 MB. Actual 9507 MB Passed
Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2009-11-14_08-16-57PM. Please wait ...
Please specify JRE/JDK location ( Ex. /home/jre ), /bin/java should exist :/usr/lib/jvm/java-6-openjdk
tomhofte@tomhofte-laptop:~/downloads/soa_11112/Disk1$ Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/xawt/libmawt.so


I assumed that something was wrong with my JDK version so I decided to install JRockit Realtime JVM version 6. After installing JRockit Realtime JVM version 6 and using this Java distribution for installing WLS and SOA Suite everything was able to install without any problems. The JRockit version I used is available from here.

Note: this will definitely not mean that FMW 11.1.1.2 will only install with JRockit Realtime JVM version 6! It is only that this made it work for me and in case you hit the same issue you now how I solved it :)


Configuring JDeveloper

After I had installed JDeveloper, I noticed that the SOA Composite editor extension is not part of the JDeveloper 11.1.1.2 bundle as it was with the previous version...so...Go to Help -> Check for Updates and select the SOA Composite editor extension:
Install the extension and restart JDeveloper to activate the update.

Activate the Preview Spring component designer
(Thanks to this posting)
To activate the Spring component in the Component palette of the Composite editor in JDeveloper, you have to change the soa-config.xml file that can be found in JDEV_HOME/integration/seed/soa/configuration. Uncomment the following the part and restart JDeveloper



${SPRING_COMPONENT_NAME_L}
${SPRING_COMPONENT_FOLDER_NAME_L}
spring
.xml
oracle.tip.tools.ide.spring.sca.SCAComponentSpring
${SPRING_COMPONENT_DESC}
${SPRING_COMPONENT_DESC}
/oracle/tip/tools/ide/spring/sca/images/springcomponent.png
/oracle/tip/tools/ide/spring/sca/images/springcomponenticon_dia.png

/oracle/tip/tools/ide/spring/sca/images/springTop.png
/oracle/tip/tools/ide/spring/sca/images/springMiddle.png
/oracle/tip/tools/ide/spring/sca/images/springMiddleShort.png
/oracle/tip/tools/ide/spring/sca/images/springBottom.png
231,231,234
192,194,203



All of the above did the job for me.

Tuesday, November 10, 2009

Monitoring Oracle AQ message systems with SQL based User defined Metrics in Oracle Enterprise Manager

By default Oracle Advanced Queueing (AQ) provides monitoring views (in this posting we use the V_$AQ view) to monitor things like
  • Number of waiting messages per queue
  • Number of expired messages per queue
  • Number of messages on status ready per queue
  • Average waiting time per queue
  • Total waiting time per queue
In large messaging systems it is important to detect possible delays and bottlenecks at an early stage. The above metrics can help you with this. Of course it is possible to write a custom monitoring application to make monitoring information accessible, but in most large environments it makes more sense to use a dedicated monitoring product that is able to monitor your complete application environment and provides a single monitoring console.

Oracle Enterprise Manager (OEM) is such a tool. OEM provides functionality to specify User-defined SQL-based metrics that allows you to easily integrate your own SQL monitoring scripts in OEM together with defined thresholds on the metrics, OEM will trigger alert notifications. The SQL queries below can be used for creating SQL based User-defined metrics in OEM to monitor specific queues on specific aspects:


-- Average wait metric
select dbaq.name, vaq.average_wait from sys.dba_queues dbaq, sys.V_$AQ vaq where dbaq.name in ('SOME_Q_A', 'SOME_Q_B') and dbaq.qid = vaq.qid

-- Total wait metric
select dbaq.name, vaq.total_wait from sys.dba_queues dbaq, sys.V_$AQ vaq where dbaq.name in ('SOME_Q_A', 'SOME_Q_B') and dbaq.qid = vaq.qid

-- Expired messages metric
select dbaq.name, vaq.expired from sys.dba_queues dbaq, sys.V_$AQ vaq where dbaq.name in ('SOME_Q_A', 'SOME_Q_B') and dbaq.qid = vaq.qid

-- Ready messages metric
select dbaq.name, vaq.ready from sys.dba_queues dbaq, sys.V_$AQ vaq where dbaq.name in ('SOME_Q_A', 'SOME_Q_B') and dbaq.qid = vaq.qid;



Notes:
  • The queries are Two-Column queries and the Metric type is Number
  • Determine a correct value for Consecutive Occurrences Preceding Notification option to prevent false positives
  • Set a correct interval. Keep in mind that monitoring causes some minor overhead...so don't set the interval too small.. 30 minutes should be sufficient in most scenario's

Set up a Weblogic Server 11g (10.3.1) JMS Store and Forward demo

Weblogic Server (supported from 9.x) contains JMS Store-and-Forward (JMS SAF) functionality. Basically this functionality makes it possible to receive messages on a specific server instance (proxy), forward the messages to different Weblogic server instances and process them on those 'hidden' instances or forward them again...In case the processing server is unavailable the message will be automatically redelivered when the server is available again..You can think about many use cases in which JMS SAF can be very useful. For example, in the situation in which you don't want to stop the message communication when an update of 'processing logic/functionality is needed, JMS SAF can increase the high-availability of your messaging solution. Also it can be used to off-load complex message processing to dedicated servers.

In this posting I will describe how you can set up JMS SAF using Weblogic Server 11g (10.3.1) with a domain configuration consisting out of 1 AdminServer and 2 non-clustered Managed Servers serve in the roles of sender (or actually the forwarder) and receiver.

I skip the domain set up and assume you are familiar with it. To define the JMS SAF resources the best thing to do is to follow the steps that are described Oracle Fusion Middleware 11g SAF guide. I will a not repeat them in this blog.. In its place, I will give additional explanation about specific configuration steps and things you have to do but which are not covered completely in the guide.

Receiving Side - Extra
  • Create a JMS Server
  • Create a Subdeployment in the receiving JMS module and target it to the JMS Server
  • Create a destination queue and remember the JNDI name that you choose. We need it when the sending side will be configured. Target the queue to the JMS module's Subdeployment
  • Create also Connection factory at the receiving side (At least I did it. However, you could try not to create a connection factory, because the sending side never uses it..). In the picture below you can see the configuration of the JMS resources at the receiving side that I have used in my demo:



Sending Side - Extra
  • Create a JMS Connection Factory in the sender JMS module. Use the default settings and and choose a easy-to-remember JNDI name. We need it in the Java client to test the JMS SAF configuration.

Sending Side - Additional notes
- I simply used the default settings for
  • the persistent store of the SAF agent
  • targeting and subdeployment
  • the type of error handling (log). If you decide to use an Error destination, make sure that the queue is targeted to same JMS server/Subdeployment as used for the SAF queue. Most probably, this will mean that you have to create a Subdeployment instead of using the default as I did :)
- For the SAF queue you have to use the JNDI name that you have chosen during the configuration of the destination queue at the receiving side for the remote JNDI location. For simplicity, you can use the same for the local JNDI name
- The JNDI name of the SAF Remote Destination will serve as the prefix of the local JNDI name that you defined for your SAF queue. Keep that in mind when you try to connect to the SAF remote queue (see further on in this posting for in the Java example)


Here's the overview of the JMS SAF resources in the JMS module, which is targeted to the sending server, that I have used in my demo set up:




JMS SAF remote Java client
Now that we have finished the Weblogic Server 11g JMS SAF configuration, we can test it by using a simple Java client. The code fragment below shows the code that you can use to test your configuration. Please note:

  • Import the J2EE 1.5 and Weblogic Remote client libraries in JDeveloper 11g
  • If you are not sure about the exact JNDI binding names for the Connection Factory and JMS destination, you can browse the JNDI tree of the sending server (Admin Console -> Environment -> servers -> -> Configuration/General tab)
  • You can either use '.' or '/' as the separator in your JNDI name


String CFName = "jms/ConnectionFactorySending";
String destName = "jmssaf.RemoteDestjms.Queue_Receiving";

Connection conn = null;
Session session = null;
MessageProducer prod = null;
try{
//Set the Initial Context properties
Properties env = new Properties( );
env.put(Context.SECURITY_PRINCIPAL, "weblogic");
env.put(Context.SECURITY_CREDENTIALS, "welcome1");
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,
"t3://localhost:7004");

InitialContext context = new InitialContext(env);

//Lookup connection factory
QueueConnectionFactory queueConnectionFactory =
(QueueConnectionFactory) context.lookup(CFName);

//Create a connection and session
conn = queueConnectionFactory.createConnection();
session = conn.createSession(false, 0);

//Lookup queue
Queue q = (Queue) context.lookup(destName);

//Send message
prod = session.createProducer(q);
TextMessage msg = session.createTextMessage();
msg.setJMSMessageID(Guid.newInstance().toString());
msg.setText("SAF Test message");
prod.send(msg);

}
catch(NamingException ne){
System.out.println("NamingException: "+ne.toString());
}
catch(JMSException jmse){
System.out.println("NamingException: "+jmse.toString());
}
finally{
try{
prod.close();
session.close();
conn.close();
}
catch(Exception e){
System.out.println("Excepion in finally branch: "+e.toString());
}
}


Run your program to send a message to the sending server. Before you do this make sure the receiving server is not running to check if SAF is working as expected. When the message is submitted, check the Monitoring tab in the Sending SAF agent configuration screen to check if the message is stored and waits for redelivery (from here you are able to perform more management tasks, like pausing forwarding etc.). When you start the receiving server the message will be redelivered automatically to the receiving server..

This blog serves as a starting point for using JMS SAF. More info about all the specific configuration options and monitoring/management options can be found here.