PTP message example
- Last Updated: August 26, 2021
- 1 minute read
- OpenEdge
- Version 12.2
PTP message example
A PTP messaging example consists of the basic steps described this topic.
Creating a PTP session
In the following session example, the application creates a session object
by calling ptpsession.p persistently.
|
Creating the session object specifies the connection parameters to the JMS-provider Broker. This allows an application to set different session-level attributes before starting the JMS session. The connection to the JMS-provider Broker and the JMS session does not occur until the application calls the beginSession procedure.
Connecting to the broker
In the following connection example, the OpenEdge application connects to the JMS-provider Broker to begin exchanging messages.
|
Creating a Message Consumer
The OpenEdge client requires a queue for sending messages. You create a queue using the JMS-provider console (for example, Sonic Management Console). Queues must be defined before starting your session. Then you create a Message Consumer to receive requests from queue, as follows:
|
Preparing to receive messages
The OpenEdge application begins listening on the queue and prepares to receive messages from the queue, as follows:
|
The Message Consumer (hConsumer handle)
listens on myqueue and handles messages using the myintproc internal procedure. The startReceiveMessages procedure starts receipt of incoming messages.
Sending messages to the queue
The application sends a message to the queue using the sendToQueue procedure, as follows:
|
Receiving messages from the queue
The Message Consumer receives a message from the queue and executes the business logic.
Deleting a message
The application deletes the messages after it finishes using them, as shown in the following example.
|
PTP Message Summary
To see the full sample code for sending and receiving a message using a PTP session, see PTP message example summary.