|
From: Patrick Y. <kc...@ce...> - 2004-09-01 09:03:17
|
The easiest way to receive message is to implement a MessageListener,
and then pass the implementation to Request object's constructor, like
what you have done. The onMessage method of the MessageListener
implementation will be invoked whenever there are messages received. If
there are more than one message received, the onMessage method will be
invoked several time, in a one-message-per-call manner. So, in your test
case, have you tried to make your main program long-running so as to
receive all the messages?
Regards, -Patrick
Rajiv Mannath wrote:
> 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);
> }
> }
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by OSTG. Have you noticed the changes on
> Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
> one more big change to announce. We are now OSTG- Open Source Technology
> Group. Come see the changes on the new OSTG site. www.ostg.com
> _______________________________________________
> ebxmlms-general mailing list
> ebx...@li...
> https://lists.sourceforge.net/lists/listinfo/ebxmlms-general
|