Official Content

The QueueMessage Data Type defines the messages that are sent/received once the connection to the message queue is established (see Queue Data Type).

Properties

Text Is the text of the message sent or received.
Priority Indicates the message priority.
MessageID Allow to set the messageID of the message
CorrelationID Allows to set the CorrelationID of the message
Properties Collection of properties that allows to send custom headers in a message

Text

This is the text contained in the message that is sent or received.

&message.text = "This is a message" 

Priority

Indicates the priority of the message. It may be anywhere from 0 to 9.

&message.priority = 7 

MessageID

Indicates the ID of the message (only some message queues allow to set the ID from the client, if it is not allowed this property will be ignored)

&message.MessageID = "ID" 

CorrelationID

Indicates the Correlation ID of the message.

&message.CorrelationID = "CorrID" 

Properties

Collection of properties that allows to send custom headers in a message

&message.properties.set(&header_name,&header_value)
&header_value = &message.properties.get(&header_name)

Complete example of how messages are sent and received

&queue = Queue Data Type
&message = QueueMessage Data Type
&char = Character

1. Provider settings

<JMS_Providers>
 <Provider>
   <Name>queueProvider</Name>
   <User></User>
   <Password></Password>
   <Type>Queue</Type>
   <Factory>com.sun.enterprise.naming.SerialInitContextFactory</Factory>
   <URL>iiop://myserver:1050</URL>
   <JNDI_ID>QueueConnectionFactory</JNDI_ID>
   <Queue_Name>Queue</Queue_Name>
 </Provider>
</JMS_Providers>

2. Sending a message

&queue.Provider=queueProvider
&ret = &queue.Connect()

//

&message.Text = "First message"
&message.Priority = 7
&char = &queue.Send(&message)
//
&message.Text = "Second Message"
&message.Priority = 6
&char = &queue.Send(&message)

 3. Receiving a message

&queue.Provider = queueProvider 
&ret = &queue.Connect() 

for &message in &queue 
      msgbox(&message.text) 
endfor 
&queue.Disconnect()

Scope

Objects: Procedures, Web Panels, Transactions
Languages: Java, .NET
Interfaces: Web





Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant