Example: /RabbitMQ/amqp_sendstring

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/RabbitMQ/amqp_sendstring


Required plugins for this example: MBS RabbitMQ Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /RabbitMQ/amqp_sendstring

This example is the version from Mon, 14th Mar 2021.

Project "amqp_sendstring.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() Const hostname = "192.168.2.70" Const port = 5672 Const exchange = "test" Const routingkey = "test" Const messagebody = "Hello World" Dim conn As New RabbitMQConnectionMBS If Not conn.NewTCPSocket Then MsgBox "Failed to create TCP socket" return End If Dim status As Integer status = conn.OpenSocket(hostname, port) If status <> 0 then MsgBox "Failed to open TCP socket" Return End If Dim r As RabbitMQRPCReplyMBS r = conn.LoginPlain("/", 0, 131072, 0, "test", "test") If Failed(r) Then Return Call conn.ChannelOpen(1) r = conn.RPCReply If Failed(r) Then Return Dim props As New RabbitMQBasicPropertiesMBS props.Flags = props.kFlagContentType Or props.kFlagDeliveryMode props.ContentType = "text/plain" props.DeliveryMode = 2 // persistent delivery mode // Dim ErrorCode As Integer = conn.BasicPublish(1, exchange, routingkey, False, False, props, messagebody) If ErrorCode <> 0 Then MsgBox "Failed to publish." Return Else MsgBox "Sent" End If r = conn.ChannelClose(1, RabbitMQRPCReplyMBS.kReplySuccess) If Failed(r) Then Return r = conn.ConnectionClose(RabbitMQRPCReplyMBS.kReplySuccess) If Failed(r) Then Return Quit End EventHandler
Function Failed(r as RabbitMQRPCReplyMBS) As Boolean If r = Nil Then Return True End If Select Case r.Type Case r.ResponseTypeNone Break Case r.ResponseTypeNormal Return False // okay Case r.ResponseTypeLibraryException MsgBox "Library error: "+Str(r.LibraryError)+" "+RabbitMQConnectionMBS.ErrorString(r.LibraryError) Return True Case r.ResponseTypeServerException Dim d As Dictionary = r.MethodDecoded Dim c As String = d.Lookup("ReplyCode", "") Dim t As String = d.Lookup("ReplyText", "") MsgBox "Server error "+c+": "+t If t = "" Then Break Return True end Select End Function
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

The items on this page are in the following plugins: MBS RabbitMQ Plugin.


💬 Ask a question or report a problem