Tuesday, April 05, 2011

Understanding and Configuring Store and Forward(SAF) in SOA Suite 11g

Store and Forward has basically the same functionality as that of Bridge however the main extra point here is that the message are store in the source also.You can get a better definition of S-A-F from this documentation.It provides reliable messaging because even thought the target is not available it will keep the message in persistence store and will try once the target system will be active.


I am using two domains to configure the same.In this exercise we will configure the JMS Server,JMS module,Sub deployment and connection factory and simple queue ,we will create SAF agent,SAF context and SAF imported destination queue.This will be more clear as we will move forward in our exercise.

At my end i have two domain

DomainA running in 7001 port
DomainB running in 7777 port

I have not created a separate managed server the soa server is running in adminserver itself.

I will first create the required fileds in DomainA

In domainA we will create JMS Server,JMS Module,Subdeployment,Connection Factory and Queue in the same order.

So log in to Admin console

http://localhost:7001/console

Create a JMS Server and point it to your admin server.



Now create a JMS module also and target it to admin server.



Create a subdeployment and target it to the JMS Server you have just created.



Create a connection Factory and a Queue with their target pointed to the subdeploymnet which you have just created.

Give some jndi name to connection factory and queue as shown




Now log in to the other domain and Create a Store and Forward AGent

Go to Services-->Messaging-->Store and Forward AGents

and make it as Sending only as shown



Create a JMS module and target it to the admin server.



create a subdeployment and target it to the SAF agent that you have created as shown below



Now create a Remote SAF context and in the url specify the url for the DomainA.
Specify the user name and password.



create a remote SAF destination.

Choose the remote SAF context as the one you have created earleir.

Give some JNDI prefix.



NOw go to queue tab in SAF imported destination and create a queue.

Here specify the JNDI name of the remote queue as the JNDI name of queue which you have created in domain A.

Specify some local JNDI name also for local server to interact with queue.



You have to make sure that the SAF imported Destination is pointing to the Subdeployment which you have created.



now create a conenction factory and also point it to the subdeployment which you have created.So in all your JMS module will contain following



so now we are done with the set up

Now the only thing is to post the message to the SAF queue.

For this purpose we will use the Default sample that is provided in

WL_HOME\samples\server\examples\src\examples\jms\queue folder to send messgaes to the SAFQueue.

The Java program is QueueSend.java.

I am not good in java programming otherwise i would have wished to write my own java program ,however you can do a search in google and find a number of links which says how to post a message to a queue.

Again while posting your message to the SAF queue you have to take care of two things

Since we have defined our SAF context and SAF remote destination in Domain B we have to use the conenction factory that we have defined in domain B.

Further one important point is that name of the queue

The name of queue which should be provide is prefix+local JNDI name of queue

In my case i have give prefix as "Ankit" and the local JNDI name for my queue is

LocalSAFqueue

So the name of queue which i should use in my case is

AnkitLocalSAFqueue.

Now once you have made the changes in your QueueSend.java code.

YOu can compile it.

Save the project in some folder location.

Open a command prompt and navigate to the location where java program is saved and do a javac QueueSend.java

And as expected you will a series of error like this


C:\SendQueueJava>javac QueueSend.java
QueueSend.java:7: package javax.jms does not exist
import javax.jms.*;
^
QueueSend.java:31: cannot find symbol
symbol : class QueueConnectionFactory
location: class QueueSend
private QueueConnectionFactory qconFactory;
^
QueueSend.java:32: cannot find symbol
symbol : class QueueConnection
location: class QueueSend
private QueueConnection qcon;
^
QueueSend.java:33: cannot find symbol
symbol : class QueueSession
location: class QueueSend
private QueueSession qsession;
^
QueueSend.java:34: cannot find symbol
symbol : class QueueSender
location: class QueueSend
private QueueSender qsender;
^
QueueSend.java:35: cannot find symbol
symbol : class Queue
location: class QueueSend
private Queue queue;
^
QueueSend.java:36: cannot find symbol
symbol : class TextMessage
location: class QueueSend
private TextMessage msg;
^
QueueSend.java:48: cannot find symbol
symbol : class JMSException
location: class QueueSend
throws NamingException, JMSException
^
QueueSend.java:65: cannot find symbol
symbol : class JMSException
location: class QueueSend
public void send(String message) throws JMSException {
^
QueueSend.java:74: cannot find symbol
symbol : class JMSException
location: class QueueSend
public void close() throws JMSException {
^
QueueSend.java:97: cannot find symbol
symbol : class JMSException
location: class QueueSend
throws IOException, JMSException
^
QueueSend.java:50: cannot find symbol
symbol : class QueueConnectionFactory
location: class QueueSend
qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
^
QueueSend.java:52: cannot find symbol
symbol : variable Session
location: class QueueSend
qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
^
QueueSend.java:53: cannot find symbol
symbol : class Queue
location: class QueueSend
queue = (Queue) ctx.lookup(queueName);
^
14 errors


This is because you have not set the JAVA HOme and other necessary jar file in the path.

In order to make it simle just execute the setWLSEnv.cmd command

C:\SendQueueJava>C:\SOA\wlserver_10.3\server\bin\setWLSEnv.cmd

It will automatically set everything for you.



now run your program

java QueueSend t3://localhost:7777



Now you can check the data is publised in the remote queue of domainA

Now for testing purpose if SAF really works the way it is supposed to way . I shut down the domainA and then tried to insert the data in the SAF queue.

I send another data to check if any error occurs,I couldn't got any exception in my command console.Now i started the domainA server also.

and with all my expectation as soon as i started domainA all the data got published to remote queue

No comments: