|
From: Gait B. <gai...@ti...> - 2003-02-03 10:02:42
|
Hi Frankie,
Re waiting time: hadn't thought of it that way. Suggest to change the =
Request.java to cover that thinking, try this:
=3D=3D=3D=3D
diff -r1.48 Request.java
275c275,280
< waitInterval =3D Constants.REQUEST_MIN_WAIT_INTERVAL;
---
> if( Constants.REQUEST_MIN_WAIT_INTERVAL < customInterval) {
> waitInterval =3D Constants.REQUEST_MIN_WAIT_INTERVAL;
> }
> else {
> waitInterval =3D customInterval;
> }
=3D=3D=3D=3D
Since I'm not a hardcore Java programmer, I'm not entirely sure how =
thread safety comes into play. I can give you the scenario, though: I =
set up a typical test scenario with a sender (using the Monitor for =
this), a Reflector (a Request based listener that constructs and sends a =
reply message) and a PayloadVerifier (also a Request based listener, not =
using the code below). The SendPanel of the Monitor is patched so that =
it saves the message and its header to disk as well, and the =
PayloadVerifier compares the reply message with the saved message and =
header. After registering the Reflector and the PayloadVerifier with the =
MSH, those clients are stopped, and I send about 20 messages to the MSH, =
targeted at the Reflector. Then the PayloadVerifier and Reflector are =
restarted (in that order). With a 100ms customInterval and the patch =
above, all goes well, but with a 10ms customInterval, only three =
messages are received. Subsequent messages are ignored until the MSH is =
restarted (not completely tested on what exactly to restart, could be =
just restarting the clients would be enough).
All this running on my 500MHz laptop with 256Mb memory, tomcat 4.1.10 =
and j2sdk 1.4.1 and Win2000pro. I can do more tests, but I'm a little =
pressed for time at the moment :-).
Re db connection: I'm running against hsqldb, very convenient in the =
normal setup, especially when testing and you frequently need to clean =
the db's. But when running the MSH and starting up the code as follows:
=3D=3D=3D=3D
String cpaID =3D "*";
String conversationID =3D "*";
String service =3D "*";
String action =3D "PayloadVerify";
ApplicationContext ac =3D new ApplicationContext(
cpaID, conversationID, service, action);
String transportType =3D "HTTP";
String toMshUrl =3D "http://localhost:8080/msh";
URL url =3D new URL(toMshUrl);
MessageServiceHandler msh =3D new MessageServiceHandler();
MessageServiceHandlerConfig cfg =3D new MessageServiceHandlerConfig( =
ac, url, (MessageListener)this, transportType, 2, "30000" );
MessageServiceHandlerConnection con =3D msh.register(cfg);
try {
while(true)
{
EbxmlMessage msg =3D con.getMessage();
System.out.println("Pulled a message, id =3D " + =
msg.getMessageId());
}
}
catch(Exception e) {
e.printStackTrace();
=20
}
msh.destroy();
=3D=3D=3D=3D
I get the following trace:
=3D=3D=3D=3D
log4j:WARN No appenders could be found for logger =
(hk.hku.cecid.phoenix.message.
handler.MessageServiceHandler).
log4j:WARN Please initialize the log4j system properly.
Info: using property file in /C:/ebxmlms/sample/msh.properties.xml
hk.hku.cecid.phoenix.message.handler.MessageServiceHandlerException: =
Cannot crea
te database connection: The database is already in use by another =
process
at =
hk.hku.cecid.phoenix.message.handler.MessageServiceHandler.<init>(Unk
nown Source)
at payloadverify.run(payloadverify.java:33)
at payloadverify.main(payloadverify.java:14)
=3D=3D=3D=3D
With tomcat shut down, the trace is as follows:
=3D=3D=3D=3D
PayloadVerify setting up...
log4j:WARN No appenders could be found for logger =
(hk.hku.cecid.phoenix.message.
handler.MessageServiceHandler).
log4j:WARN Please initialize the log4j system properly.
Info: using property file in /C:/ebxmlms/sample/msh.properties.xml
java.lang.NullPointerException
at =
hk.hku.cecid.phoenix.message.handler.MessageServiceHandler.register(U
nknown Source)
at payloadverify.run(payloadverify.java:35)
at payloadverify.main(payloadverify.java:14)
=3D=3D=3D=3D
Re retrieving messages by id: I agree on the MessageOrder, but what can =
I say, I'm a control freak :-).
Re getPendingMessages: that possibility occurred to me after I hit the =
send button :-).=20
Many thnx, Gait.
----- Original Message -----=20
From: Frankie Lam=20
To: ebx...@li...=20
Sent: Monday, February 03, 2003 9:54 AM
Subject: Re: [ebxmlms-develop] Why the delay after receiving a =
message?
Dear Boxman,
The waiting time is reset to REQUEST_MIN_WAIT_INTERVAL when the last =
polling to MSH shows positive response, i.e. a new message arrives. It =
is because we expect that the client would specify an interval larger =
than that and resetting it causes the messages to be delivered to the =
client application faster. But we are quite concerned about the message =
loss for frequent polling. It seems to me that it is a thread-safety =
issue.
Could you please tell us more about "issues with database connection" =
using hsqldb? And also the use of "getPendingMessages()" is to obtain =
the number of messages pending to be *sent* rather than *received*. So =
perhaps there is a misunderstanding here.
It's a good suggestion that the messages can be retrieved by message =
ID. However, I think the ebMS specification does not allow such use if =
"MessageOrder" is enabled, when the messages must be delivered =
sequentially to the application in a specified order. Personally I =
suggest that you may get all the messages and put it in your own buffer =
for further processing.
Best regards,
Frankie
----- Original Message -----=20
From: Gait Boxman=20
To: ebx...@li...=20
Sent: Monday, February 03, 2003 4:35 PM
Subject: [ebxmlms-develop] Why the delay after receiving a message?
Hi team,
while trying to speed up the receiving process (one of our apps is =
batch oriented and typically needs to retrieve any buffered messages as =
fast as possible without waiting for new ones), I found that the wait =
time is reset to REQUEST_MIN_WAIT_INTERVAL after receiving a message =
from the server (in Request.java), rather than the value set explicitly. =
While my testing showed having 2 listeners polling every 10ms will =
result in message loss (I patched Request.java to leave the value at the =
customInterval), I am curious about the cause behind that, and a =
possibly more accurate timing. For instance, making my listeners poll at =
100ms went just fine.
Trying to bypass the polling mechanism in Request.java and going =
directly through the MessageServiceHandlerConnection, as suggested a =
while ago to Jason by Ng, gave me some issues with the database =
connection when the MSH is running (using hsqldb) and with null pointers =
when the MSH is not running.=20
Ideally, I'd like to retrieve the number of messages queued in the =
MSH for my AC, and then just retrieve those messages in a burst. =
However, getPendingMessages always returns an empty list, rather than a =
list of queued messages, so I can't even count the number pending. It =
would be even cooler if I could retrieve the messages by their =
messageId.
thnx, Gait.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gait Boxman
Manager Advanced Technology & Standards
TIE Product Development BV
Amsterdam, The Netherlands
Tel: +31 20 658 9091 Fax: +31 20 658 9945
E-mail: gai...@ti... WWW: www.TIEglobal.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |