|
From: Rajiv M. <rma...@ho...> - 2004-08-03 20:33:01
|
All,
I am having problems querying the Request for ReceivedMessages. I am
sending and receiving messages from the same server, but I don't think this
should cause a problem. Once I send my message, I do see in the log as well
as in the database that the message has been received. The receivedmessage
table has an additional row in it with the same messageID of the message
that was sent.
In my class that queries for new messages, when I create a new Request
object I pass null for the MessegeListener parameter. Is that a problem?
Also, the toMshURL I use is a bogus URL. I'm just using this to listen for
messages. Does this need to be URL to a MSH server, if I'm just listening?
When I query the the request for new messages, I get a zero length array
back. The class that queries the request also implements the
MessegeListener Interface. I have tried passing itself as a messageListener
when I create the Request object. When I take this route, the onMessage
method is called when a new message is received, however if I send to
messages back to back only the last message gets picked up? I am sending
the same message, but since they have different messageID's I don't think
this should be a problem. Again, the messages are stored in the
receivedMessage table, but only one of them triggers the onMessage() method.
I have included some of the code. Any help would be greatly appreciated.
Raj
/**
* Method to register this listener with the message server.
*
* @throws ServerUnavailableException if the object cannot register
* with the server
*/
private void registerListener() throws ServerUnavailableException{
ClientMessageListenerImpl messageListener=null;
System.out.println("Registering...");
ApplicationContext ac = new ApplicationContext(
cpaID, conversationID, service, action);
try {
this.mshReq = new Request(ac, this.toMshUrl, null, TRANSPORTTYPE);
/* Use this if you want the Request object to callback. However
* if multiple messages are sent in close succession, only one of
* them triggers the callback method. Why is this?
*
* this.mshReq = new Request(ac, this.toMshUrl, this, TRANSPORTTYPE);
*/
} catch (RequestException e) {
throw new ServerUnavailableException(e);
}
}
/**
* Queries the server for any new messages that match the registered CPA.
* @throws ServerUnavailableException if the server cannot be queried.
* @throws MessageUnreadableException if a message cannot be read.
*/
public void getNewMessages() throws ServerUnavailableException,
MessageUnreadableException{
String[] messageIDs;
EbxmlMessage ebmessage;
BulkRequest request;
try {
messageIDs = this.mshReq.getReceivedMessageIds();
if (messageIDs != null) {
System.out.println("Number of ReceivedMessages:"+messageIDs.length);
for (int i=0;i<messageIDs.length;i++) {
request = new BulkRequest(generateFileName(messageIDs[i]));
System.out.println(messageIDs[i]);
ebmessage = mshReq.receive(messageIDs[i]);
processEbxmlMessage(ebmessage);
}
} else {
System.out.println("No received Messages");
}
} catch (RequestException e) {
throw new ServerUnavailableException(e);
}
}
|