activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olsonpm <>
Subject IConnection.start() - optional?
Date Tue, 22 Mar 2011 19:21:44 GMT
I was trying to implement a persistent producer using NMS and ActiveMQ.  I
realized the function isStarted wasn't returning true, even though my
messages were successfully being sent.  I chalked this up to not calling
connection.start().  However, if the connection isn't running, how are the
messages sending?

Here's the following code that runs as intended

Imports System
Imports System.Collections.Generic
Imports System.Text

Imports Apache.NMS.ActiveMQ
Imports Apache.NMS

Module Module1

    Private Const URI As String = "myURI"
    Private Const DEST As String = "myQueue"

    Sub Main()

        Console.Write("press any key to start: ")

        Dim df As ConnectionFactory = New ConnectionFactory(URI)
        Dim conn As IConnection = df.CreateConnection()
        Using conn
            Dim session As ISession = conn.CreateSession
            Using session
                If (conn.IsStarted) Then
                    Console.WriteLine("connection has started") '<--doesn't
                End If
                Dim prod As IMessageProducer = session.CreateProducer(New
                Dim msg As ITextMessage = prod.CreateTextMessage()
                msg.Text = "Hello world"
                msg.Properties("OriginUnit") = "3039"
                msg.Properties("OriginDept") = "MME"
                msg.Properties("MessageType") = "AutomatedPalletScan"
                Console.WriteLine("Sending: " & msg.Text)

                Console.Write(vbNewLine & "press any key to end: ")
            End Using
        End Using
    End Sub

End Module

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message