' Collection of code snippets by Arne Vajhøj 
' (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
﻿Imports System
Imports System.Text

Imports RabbitMQ.Client

Namespace Pub
    Public Class Program
        Private Const HOST As String = "localhost"
        Private Const PORT As Integer = 5672
        Private Const UN As String = "guest"
        Private Const PW As String = "guest"
        Private Const TNAME As String = "TestT"
        Private Const PAYLOAD As String = "<data>" & vbCr & vbLf & "    <id>123</id>" & vbCr & vbLf & "    <name>ABC</name>" & vbCr & vbLf & "</data>"
        Public Shared Sub Main(args As String())
            Dim cf As New ConnectionFactory()
            cf.HostName = HOST
            cf.Port = PORT
            cf.UserName = UN
            cf.Password = PW
            Using con As IConnection = cf.CreateConnection()
                Using chan As IModel = con.CreateModel()
                    chan.ExchangeDeclare(TNAME, ExchangeType.Topic)
                    For i As Integer = 0 To 2
                        chan.BasicPublish(TNAME, "", False, Nothing, Encoding.UTF8.GetBytes(PAYLOAD))
                    Next
                End Using
            End Using
        End Sub
    End Class
End Namespace
