Does anyone can please tell why how can I write message to the top of the queue?
Well, it very much depends on what type of queue and what you mean by "the top" of the queue.
I'm going to guess that we are talking about JMS queues and that you want the message to be received from the queue first, ahead of any other messages which may have been sent previously but not received yet.
You can do this by setting the JMSPriority when you send the message to the queue. However, the exact meaning and implementation of JMSPriority varies from one JMS provider to another and in fact the JMS spec does not require a JMS provider to implement this. Read the documentation for whatever JMS provider you are using.
Actually in my case, I am writing the message on the Host remote queue using COBOL and then the messages is transmitted to the local queue on the unix machine. What I want to do is put the message at the top of the queue using COBOL MQ and then the message would be read using MDB at the local queue.
I don't know much about COBOL but I do know that MQ supports priorities for messages. So, when you send the message to the MQ queue you can specify a higher than normal priority for that message, which will cause it to be read off the queue ahead of other messages with a lower priority. How you actually do that with COBOL, I don't know. I think that this is the point at which you have to go back to the MQ documentation and read how to do it. I used to program MQ using RPG many years ago and the documentation was very good, so I imagine it's the same for COBOL.