Guos Hu

Greenhorn
+ Follow
since Jan 28, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Guos Hu

Hi Mark,

When I talk about Service Oriented Architecture, I think there are 2 concepts:

(1) The first concept is SOA an architecture style used to design applications and business processes at a service level, meaning every computing unit of work is defined as a reusable service. The features of this SOA concept include loosely coupled, coarse grained, re-useable etc.

(2) The second concept is that SOA is not only an architecture style, but also an implementation style: the application must be implemented with WSDL, UDDI, XML, SOAP etc.

With the first concept, even pure Java applications without WSDL can be designed as Service Oriented. So I like it better.

Another question: why SOA is platform and protocol independent? I think it is simply because all Vendors agree that and almost all important platform and protocal support the SOA requirement. Just like all browser support HTML. Similar to CORBA (of course beter than CORBA because it is a newer solution).

What do you think about the above questions?

Thanks a lot.
16 years ago
Hi everyone,

I am trying to send a queue message with reply. The message was sent and received successfully. But the the queue sender never received the reply from the receiver.

The debug tells me that: before the TextMessage was sent, I can see that the replyTo is a "TemporaryQueue". When the TextMessage was received, the string message and long property "ID" were all correct, but the "replyTo" of the TextMessage is "null".

I think the "null" is the reason of reply message never received. But I do not know what is wrong. The following is my source code.

Thanks a lot for help!


package com.jmstest;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TemporaryQueue;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

import org.apache.commons.logging.LogFactory;

import com.cot.express.jms.cache.JmsConnectionFactoryCache;
import com.cot.express.jms.core.JmsConstants;

public class QueueMessageSender {

private static QueueMessageSender instance;

private QueueConnectionFactory qFactory = null;
private QueueConnection qconn = null;
private QueueSession qSession = null;
private Queue queue = null;
QueueSender qSender = null;

/* temp queue for reply */
private TemporaryQueue replyQueue = null;
private long queueId = -1;
private QueueReceiver replyReceiver = null;

private QueueMessageSender() {
}

public static QueueMessageSender getInstance(){
if(instance == null){
instance = new QueueMessageSender();
}
return instance;
}

public void send() throws Exception {

try{
//(1) get Cached QueueConnectionFactory
qFactory = JmsConnectionFactoryCache.getQueueConnectionFactory(JmsConstants.QUEUE_CONNECTION_FACTORY);
//(2) create a QueueConnection with the queue connection factory
qconn = qFactory.createQueueConnection();
//(3) create a QueueSession with the QueueConnection
//qSession = qconn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
qSession = qconn.createQueueSession(false,Session.CLIENT_ACKNOWLEDGE);
//(4) JNDI lookup for the Queue
Context ctx = new InitialContext();
queue = (Queue)ctx.lookup(JmsConstants.QUEUE_NAME);
//(5) create a QueueSender with the QueueSession
qSender = qSession.createSender(queue);
//(6) create a temp queue for reply
replyQueue = qSession.createTemporaryQueue();

//Using time as topic ID
queueId = System.currentTimeMillis();

//(7)create a text message
String message = "This is a test.";
TextMessage msg = qSession.createTextMessage();
msg.setText(message);
//(8) set reply message
msg.setJMSReplyTo(replyQueue);
msg.setLongProperty("ID",queueId);
//(9) send the text message
qSender.send(msg);

//send a non-text control message to indicate the end of the message stream
qSender.send(qSession.createMessage());

//wait some time and try to get the reply message
boolean received = false;
Message replyMessage = null;
int waittime = new Integer(JmsConstants.RECEIVE_WAIT_TIME).intValue();
replyReceiver = qSession.createReceiver(replyQueue);
while (!received){
Thread.sleep(1500);
qconn.start();
replyMessage = replyReceiver.receive(waittime*1000);
String m = ((TextMessage)replyMessage).getText();
if(m.equals("success")){
LogFactory.getLog(getClass()).debug("++++++++++++++++++++++++++");
LogFactory.getLog(getClass()).debug("Message received and processed successfully!");
LogFactory.getLog(getClass()).debug("++++++++++++++++++++++++++");
}
}



}catch(Exception e){
throw e;
}finally{
try{
if(qconn != null){
qconn.close();
}
}catch(JMSException e){
//do nothing
}
}
}
}


****************************************


package com.jmstest;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.cot.express.jms.cache.JmsConnectionFactoryCache;
import com.cot.express.jms.core.JmsConstants;
import com.cot.framework.core.exception.BaseException;

public class QueueMessageReceiver {

private Log log = LogFactory.getLog(getClass());

private static QueueMessageReceiver instance;

private QueueConnectionFactory qFactory = null;
private QueueConnection qconn = null;
private QueueSession qSession = null;
private Queue queue = null;
private QueueReceiver qReceiver = null;
private Message msg = null;
private QueueSender sender = null;
private TextMessage replyMsg = null;

private QueueSession replySession = null;



private QueueMessageReceiver() {
}

public static QueueMessageReceiver getInstance(){
if(instance == null){
instance = new QueueMessageReceiver();
}
return instance;
}

private void receive() throws BaseException {
try{
//(1) get Cached QueueConnectionFactory
qFactory = JmsConnectionFactoryCache.getQueueConnectionFactory(JmsConstants.QUEUE_CONNECTION_FACTORY);
//(2) Create a QueueConnection with the QueueConnectionFactory
qconn = (QueueConnection)qFactory.createQueueConnection();
//(3) create a QueueSession with the QueueConnection
qSession = qconn.createQueueSession(true,0);
//(4) JNDI lookup for the Queue
Context ctx = new InitialContext();
queue = (Queue)ctx.lookup(JmsConstants.QUEUE_NAME);
//(5) create a QueueReceiver with the QueueSession
qReceiver = qSession.createReceiver(queue);

//(6) start the message receiver from the QueueConnection
qconn.start();
//(7) receive the message and return it
int waittime = new Integer(JmsConstants.RECEIVE_WAIT_TIME).intValue();
msg = qReceiver.receive(waittime);
TextMessage message = null;
if(msg != null && msg instanceof TextMessage){
message = (TextMessage)msg;
}

//(8) send the reply message
Queue replyQueue = (Queue)msg.getJMSReplyTo();
sender = qSession.createSender(replyQueue);
replyMsg = qSession.createTextMessage("success");
replyMsg.setJMSCorrelationID(msg.getJMSCorrelationID());
replyMsg.setLongProperty("ID",msg.getLongProperty("ID"));
sender.send(replyMsg);

}catch(Exception e){
log.error("Error in Queue receiver initialization: ", e);
throw new BaseException("Error in Queue receiver initialization: " + e.getMessage());
}finally{
try{
if(qconn != null){
qconn.close();
}
}catch (JMSException e){
//do nothing
}
}
}

}
When I type "localhost:8080/jsp" in the IE URL address, the dirctories and files within the jsp directory will be displayed. How to provent the directories and files from displaying in the IE?
Thanks!
22 years ago
I am using Struts. When I use "<a href='/someaction.do'" in a hyper links, the url in IE address displays "http://localhost/someaction.do", and I was redirected to the right page correctly (that is localhost/myapps/jsp/somepage.jsp. In struts-config.xml file, forwarding path="/myapps/jsp/somepage.jsp")
But when I use it in html form, "<html:form action="/someaction.do">, the url in IE address became "http://localhost/myapps/someaction.do", the correct one should be "http://localhost/someaction.do", and so it is impossible to get a correct redirect.
Why "/myapps" is added before "/someaction.do"? How to correct it?
Thanks
22 years ago
I am using Apache1.3.23 and Tomcat3.3.
When I type "Http://localhost:8080" in the URL address, what I see is the tomcat welcome page. When I configured my own app in "apps-myapp.xml" by using
<Context path=""
docBase="webapps/myapp"
crossContent="true"
debug="0"
reloadable="true"
trusted="false">
</Context>
, and type "Http://localhost:8080" again, my file directories under "myapp" are listed. I can only get my home page by typing
"Http://localhost:8080/myapp/jsp/index.jsp".
How to config the tomcat so that I can get my home page just by typing ""Http://localhost:8080"?
Similar problems in Apache1.3.23. When I start apache and type into "local host", I see the apache's default page which told me that the apache web server installed successfully. How to config so that I can see "/myapp/jsp/index.jsp" page when just type "localhost"?
Thanks very much!
22 years ago
I have got it!!!
Thanks all the same!
It is a really very good sites!!!
please see the questiion of new registered name Guos Hu