Skip to content

Commit a608683

Browse files
committed
ReadMsgString utility method
1 parent 4babfe2 commit a608683

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

RabbitMQ/Utils.cls

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,44 @@ ClassMethod ReadMsg(pMsgLen = 32000) As %Status
5858

5959
#Dim stream As %Stream.Object
6060
Set stream = api.readMessageStream(.list)
61-
Write !,"Body: "
62-
Do stream.OutputToDevice()
63-
Write !
61+
set body = stream.Read()
62+
Write !,"Body: ", body,!
63+
64+
65+
Zw list
66+
67+
Set sc= gateway.%Disconnect()
68+
} Catch ex {
69+
Set sc = $$$ADDSC(ex.AsStatus(), $g(%objlasterror))
70+
}
71+
72+
Quit sc
73+
}
74+
75+
/// Read one message.
76+
/// Write $System.Status.GetErrorText(##class(RabbitMQ.Utils).ReadMsgString())
77+
ClassMethod ReadMsgString(pMsgLen = 32000) As %Status
78+
{
79+
#Dim gateway as %Net.Remote.Gateway
80+
#Dim exception as %Exception.AbstractException
81+
82+
Set sc = $$$OK
83+
Try {
84+
85+
Set gateway = ..Connect()
86+
#Dim api As isc.rabbitmq.API
87+
Set api = ..GetAPI(gateway)
88+
89+
#Dim list As %ListOfDataTypes
90+
Set list = api.readMessageString()
91+
92+
Write !,"Body: ",list.GetAt(16),!
6493

6594
Zw list
6695

6796
Set sc= gateway.%Disconnect()
6897
} Catch ex {
98+
break
6999
Set sc = $$$ADDSC(ex.AsStatus(), $g(%objlasterror))
70100
}
71101

0 commit comments

Comments
 (0)