BibleGateway.com Verse Of The Day

Friday, December 03, 2010

WebLogic Annotation For MDB WorkManager

If you are like me, you have been searching the web for 2 hours looking for a way to tie your WebLogic 10g message-driven bean to a WLS WorkManager using the nice EJB3 annotations. But since you aren't me, let me save you some time.

It ain't there. Not gonna do it. Not happening for you today, my friend.

You have to do a bastardized mutt application using a combo of annotations and XML deployment descriptors (remember those?).

Allow me to save you more time by showing a more concise example, so you don't have to take a time machine back to a time when EJB2.1 and XML roamed together in dinosaur-like bliss and figure out what the descriptor should look like.

Here's an example:

My MDB class signature looks something like this....

@MessageDriven(activationConfig = {
@ActivationConfigProperty(
propertyName = "destinationType",
propertyValue = "javax.jms.Queue") },
mappedName = "jms.ens.yes943processing.queue")
public class YearEndProcessingMdb implements MessageListener {
...


And so on, with your onMessage() and all the other crap you would put in an MDB.
Then my weblogic-ejb-jar.xml file looks a bit like this....

<wls:weblogic-enterprise-bean>
<wls:ejb-name>YearEndProcessingMdb</wls:ejb-name>
<wls:dispatch-policy>Ens943WorkMgr</wls:dispatch-policy>
</wls:weblogic-enterprise-bean>

<wls:work-manager>
<wls:name>Ens943WorkMgr</wls:name>
<wls:max-threads-constraint>
<wls:name>Ens943MaxThreadLimiter</wls:name>
<wls:count>10</wls:count>
</wls:max-threads-constraint>
<wls:ignore-stuck-threads>true</wls:ignore-stuck-threads>
</wls:work-manager>
</wls:weblogic-ejb-jar>



You can tell if the thread limiter is working by deploying, chucking a bunch of messages on thequeue, and checking the WLS console.

  • Go to deployments
  • Click to expand your EAR
  • Click on the MDB name.
  • Then go to the Monitoring tab.
  • Under that click on the Workload tab.
  • Here you should see your work manager and thread constraints with the number of messages they are processing.

Monday, November 01, 2010

Oracle Service Bus - Getting XML Out of Table Column

This took me a while to figure out, and ended up being pretty simple once I knew which XQuery functions were available.

Let's say you have a table you need to query from the OSB. The result set you get back from the JCA DB adapters gets turned into XML for you. If one of the columns is a LOB containing XML, then it gets escaped using CDATA. Anything in CDATA is basically ignored by XML, XSL, XPath, etc.

It is a 2 step process to extract that value and make it usable XML:

  1. Use the fn:string() function to turn the value into a string. In this case, it strips off the CDATA wrapper and gives you a string that looks like XML.
  2. Use the fn-bea:inlinedXML() function to parse that string into XML.

You can use an ASSIGNMENT task to jam that XML into a variable, and then run any XSL, XPath, etc on it. You can also use INSERT or REPLACE tasks to embed it back into your original XML.

Enabling Oracle Trace For WLS Connection Pools

We recently had the need to run an Oracle trace to catch some database diagnostics for an OSB call flow. To enable the trace only for the sessions coming from WebLogic, I added the following to the "initSql" field in the connection pool setup screens (in the WLS console). Just remove it and save the pool settings when you're done collecting your *.trc files. Works like a charm.

SQL BEGIN DBMS_MONITOR.session_trace_enable(waits=>TRUE, binds=>TRUE); END;

Wednesday, October 13, 2010

Oracle Service Bus and JCA Adapters

If you've spent any time using Oracle's SOA suite, the first thing you will notice is their toolset kind of blows donkey. It's a half-baked patchwork of crap - some of it written by them, some of it bought from other companies and bastardized. And chock full of interesting bugs and random crashes.

So the first thing I noticed when working with the OSB for the first time (Oracle Service Bus, a.k.a. BEA Aqualogic service bus, or ALSB) is that the "Workshop" tooling lumps everything as either a "business service" or a "proxy service". That's all fine and good, but when I first started reading about integration patterns, SOA, and service buses years ago, a lot of what I learned about was JCA adapters. Where are the JCA adapters!?

If "Workshop for Weblogic 10g" is your only Oracle SOA IDE, then you might think JCA doesn't exist anymore. Oh, but it does. And chances are you need it. So here comes that patchwork - that menagerie of mismatched pieces. You need to use Oracle JDeveloper as well as Workshop for Weblogic - 2 IDE's to accomplish your 1 task.

Ugh, seriously?

This tutorial and sample, while well written, confirms it in all it's ridiculous glory. You need to launch JDeveloper to create the JCA adapter. Then you launch Workshop for Weblogic and create a business service or proxy service in your OSB project. Within that service, you have to import the WSDL that you generated from JDeveloper (as well as any XSD's and TopLink mappings).

Maybe next time Oracle will put all that into one tool? Though since they bought Sun, they have aquired even more application servers and tools, so next time you'll probably have to launch JDeveloper, Workshop, and NetBeans to get a simple service working.

A Few More SEAM Nuggets

I just came across some stuff that was supposed to be a blog post with some more SEAM tips and tricks. Since then, I've moved on to a new job, and haven't been using SEAM in my new position.

Showing Number of Matched Records in List View

When you generate a SEAM application from a database, you end up with a set of components for each table - for example a list view, record view, and record edit. When you are displaying a list of records, it is common to want to show how many records match the current query (or the total records if you went to list view without a search criteria).

You can easily get this function by accessing the "resultCount" attribute on your view, like this:

<h:outputtext value="#{yourTableList.resultCount} rows found." rendered="#{not empty yourTableList.searchResults}">

Change Default Sort Order, But Still Allow Click-To-Sort

One requirement we ran into on one of my SEAM projects was to change the default sort order for some of the list views. However, the views that the SEAM gen tool creates allows the user to click on the column headers to change sorting as well. To achieve a default sort order on initial load, and still allow clickable headers, override the getOrder() method in your List.java source like this:

@Override
public String getOrder() {
String order = super.getOrder();
if ("".equals(order) || order == null)
{
order = "col1 asc,col2 desc";//your default sort columns here
}
return order;
}


Wednesday, August 18, 2010

Good XSL And XPath Advice

A few months ago I came across a post that I've gotten a lot of mileage out of while working on the Oracle Service Bus (OSB). I can't remember where I saw it or who said it, otherwise I would cite it, but to paraphrase:
If your XPath query is not returning any results (and you think it should), it is almost always a namespace issue.

OK, so maybe it is common knowledge, common sense, or whatever for everyone else, but for me, remembering that one statement makes XSL, XPath, and XQuery much less frustrating to deal with.

Take that statement along with the issues with the default namespace, and it can be a lifesaver.

If you have an XML with a default namespace and try searching for, say "//somenode", it won't be found, because "//somenode" will only match somenode's without any namespace. The somenode's in an XML doc with a default namespace does have a namespace.

Oracle Sorting of NULL Values

Speaking of Oracle crap, a few weeks ago while working on this project, the question came up of how Oracle sorts NULL values in an ORDER BY clause. I looked it up, and learned something new. Hooray for learning new stuff. I didn't realize you can specify how to sort NULL's in your ORDER BY clause. You add "NULLS FIRST" or "NULLS LAST" like this....

SELECT * FROM sometable ORDER BY col1 ASC NULLS FIRST

ORA-24777 When Using XA Driver

Here's something we came across this past week, and after some searching, it appears to be a fairly common issue.

We are calling some PL/SQL stored procedures through JCA adapters on the Oracle Service Bus (OSB). Our connection pool on WebLogic is setup using the XA JDBC driver.

Everything was great until we called a stored procedure that queries across a database link. Then we got the dreaded ORA-24777 - use of non-migratable database link not allowed.

Turns out there are at least 3 ways to rectify this issue....

  1. Set up Oracle to use multi-threaded server, a.k.a. shared server. There are ups and downs, and depending on who you talk to, mostly downs, especially concerning performance. We haven't tried this, but it does come up often as a fix.
  2. Create a "shared" database link. The syntax is a little different than a "normal" link. This is what we did, and it worked fine.
  3. Third option, though not right for everyone, would be to use the non-XA driver.
Creating a shared link....
CREATE SHARED DATABASE LINK 
CONNECT TO IDENTIFIED BY
AUTHENTICATED BY IDENTIFIED BY
USING ;

Thursday, February 11, 2010

Quote of the Week

Someone actually said this on a status call this morning at work. He wasn't joking.

"It would be less manual if it was automated."

Thank God for the mute button on my phone, because I'm still laughing about it.