putMessage(msg: JadeGenericMessage input; options: String);
The putMessage method of the JadeGenericQueue class adds the message specified by the msg parameter to the queue. After executing the putMessage method, you can delete the msg object or initialize it for sending or receiving another message from the queue.
The method updates properties of the msg object such as the messageID and createdWhen properties.
The JadeGenericQueue instance that created the msg message object (using the createMessage method) need not be the same instance that sends the message with the putMessage method, but both JadeGenericQueue instances must use the same transport. If the msg object has previously been used to add a message to a queue by using the putMessage method or to retrieve a message from a queue by using the getMessage or getMessageByCorrelationID method, it must be initialized using the initializeForPut method defined in the JadeGenericMessage class.
If the options parameter is a null string, transport-specific default actions are taken. Options passed to this method override any specified in the defaultPutMessageOptions property.
Components that can be included in the options parameter string for the JadeMQ transport are listed in the following table. (These options are ignored for the WebSphere MQ transport.)
Component | Result |
---|---|
NoWait | The method returns immediately if the queue is full |
Timeout=milliseconds | The method waits for the specified number of milliseconds until there is enough room in the queue for a message to be sent |
Timeout=0 | The method waits indefinitely (the default implied option) |
The queue must be opened by the openQueue method defined in the JadeMessagingFactory class, with Usage=Put or Usage=All included in the options parameter.
The following example shows the use of the putMessage method to send a message to a queue.
vars factory : JadeMessagingFactory; msg : JadeGenericMessage; queue : JadeGenericQueue; begin create factory transient; queue := factory.openQueue("JadeMQ://localnode/TestQ", "Usage=Put"); msg := queue.createMessage(true); queue.getMessage(msg, "Timeout=5000"); epilog delete factory; delete msg; delete queue; end;