Wednesday, May 23, 2012

OSB and JMS Correlation Part 2

continuing...

I import the WSDL of my test service that will validate the order

I then create a Business Service based on the WSDL

I test the Service


If the custID = 1111 and the totalPrice is > 10K then the order is invalid.


Now call this from the request pipeline using a Service Callout action -


The table below explains the different "Configure" options


Now we need to set VO_REQ via an Assign action


The expression is as follows -


Save and Test


Looks good. Now I add the logic to write invalid orders to the Queue-Error.

Firstly, I created a business service to Write to the demoQueue-Error.
I then call it as follows - per default the original payload, in $body, is being written to the error Queue.



IF Expression - 


 Test 


then check the Error Queue in WLS console 








9 comments:

Anonymous said...

Hi,

If possible could you please elaborate more about the Write2JMS Class, like Where to add this class and how to execute the same? to add message into JMS. As i am from Mainframe Background, It would help me to understand more. Thanks in advance
Reddy

Anonymous said...

Hi,

If possible could you please elaborate more about the Write2JMS Class, like Where to add this class and how to execute the same? to add message into JMS. As i am from Mainframe Background, It would help me to understand more. Thanks in advance
Reddy

Anonymous said...

Hi,

If possible could you please elaborate more about the Write2JMS Class, like Where to add this class and how to execute the same? to add message into JMS. As i am from Mainframe Background, It would help me to understand more. Thanks in advance
Reddy

Anonymous said...

Hi Nell, Its Really a nice post.

Could you please provide in detail about the JAVA CLASS Write2JMS, like where to add this class and how to execute the classs, as i am from Mainframe Background it would help me to understand more in detail.

Thanks in Advance.
Reddy

Kishore Reddy said...

Hi Nell, Its Really a nice post.

Could you please provide in detail about the JAVA CLASS Write2JMS, like where to add this class and how to execute the class, as i am from Mainframe Background it would help me to understand more in detail.

Thanks in Advance.
Reddy

Kishore Reddy said...

Hi Nell, Its Really a nice post.

Could you please provide in detail about the JAVA CLASS Write2JMS, like where to add this class and how to execute the class, as i am from Mainframe Background it would help me to understand more in detail.

Thanks in Advance.
Reddy

Niall Commiskey said...

Here is sample JMS client code -

public void write2Q(String msg) throws JMSException, NamingException {
final Context ic = getInitialContext();
System.out.println("*** CONTEXT =");
final QueueConnectionFactory qcf = (QueueConnectionFactory)ic.lookup("jms/MyQCF");
// Lookup should specify the queue name that is mentioned as "mappedName" in MessageDriven Bean.
final Queue destQueue = (Queue)ic.lookup("jms/MyQueue");

final QueueConnection connection = qcf.createQueueConnection();
try {
final QueueSession session = connection.createQueueSession(false, 0);
final QueueSender sender = session.createSender(destQueue);
final TextMessage message = session.createTextMessage(msg);
sender.send(message);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
ic.close();
connection.close();
}
}

private static Context getInitialContext() throws NamingException {
Hashtable env = new Hashtable();
// Add InitialContext property assignments here.
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
// Note that by default WebLogic server is not created with security, so credentials are not needed.
// TODO: Verify the server address and port number
env.put(Context.PROVIDER_URL, "t3://localhost:7101");
env.put(Context.SECURITY_PRINCIPAL, "weblogic");
env.put(Context.SECURITY_CREDENTIALS, "Welcome1");
return new InitialContext(env);
}
}

Anonymous said...

Thanks a lot Niall for your update on my comments. I have few more.

1). Do i need to add any imports on top of java class?

2). Can i build this Java class in JDEVELOPER using JAVA Application.

Niall Commiskey said...

Yes you can build this in Jdev.

import java.util.Hashtable;

import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.TextMessage;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;