Discussions

General J2EE: Solutions for this problem? receive msg from MQ on Java Client

  1. Hi
     I have a scenario where a third party client should be able to receive msges on my local MQ. He should also be able to send msges to the Q.
     As the deadline is very short, to deliver the concept tomorrow/friday, I am seeking advice from you guys.
     The client application has to be deployed on windows platform.
     It has to listen to msges on my MQ and write the msg to the local file system.
     After writing to the file system it should be able to trigger the clients built in application, written in PL/SQL, so it can start processing the msg.
     It should be able to send messages also.
     --------------------------------------------------

     Only and partial solution that i could think of now was write a JMS client.
    Launch it as a windows service so it is continuosly running! Implications???
    After receiving the msg write to the local file system and insert the file name into the clients database table. We can have write access to their table.Client can have an trigger on the table and read the file from the system.
    Send the msg? The above solutions could be otherway round but I dont know If PL/SQL can launch a method of java program running as service. If you know please let me know.


     I would appreciate If anyone has better or more solutions or atleast can let me know the implications and the missing pieces of the above solutions. I am unaware of this technology, time is too short to learn, I would appreciate any kind of help.

    Thanks
  2. Write a JMS Client which both act as a async sender and receiver.
    When a message arrives on your local MQ, the JMS client will read this message , do some processing like invoking PL/SQL and send a reply message to your localMQ . If your are using Oracle then by using External Routines concept you can invoke method on java class from oracle stored procedure.

    Cheers,
    Mohit
  3. Thanks Mohit, Can you please give me a bit of details about Oracle external routines concept. Can you point me to some resources if possible.

    Rgds,

    Gul
  4. Is it possible to run the this particular listener and sender as windows service? The goal is to start the listener on startup and yet client should be able to restart the listener at times.

    If yes how to achieve that?

    Thanks.
  5. See this link for External Routines.
    http://sales.esicom.com/sales/oracle/appdev.816/a76939/adg11rtn.htm

    Yes it is possible to run this receiver and sender as a windows service.
    and you can also receive asynchronous message notifications from the JMS server

    To receive messages asynchronously, a client must:
    · Implement javax.jms.MessageListener:
    · public interface MessageListener {
    · void onMessage(Message message);
    · }
    · Register the message handler using setMessageListener():
    · ...
    · subscriber = session.createSubscriber(topic);
    · SubscriberMessageThread smt = new SubscriberMessageThread(this);
    · subscriber.setMessageListener(smt);
    · con.start(); // start connection
    · smt.start();
    · ...

    and use wait or notify methods.

    For creating a listener/sender a windows service just see this link:
    http://members.tripod.com/~hkseth/nt.html

    Cheers,
    Mohit
  6. Thanks alot Mohit for all the help. Will post once i get this solution to work.
  7. I am unable to download the .bat files from the link you passed me. Is there any other resource I can follow on how to run java as windows service.

    Thanks