activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olsonpm <olso...@uwec.edu>
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: ")
        Console.ReadKey()
        Console.WriteLine(vbNewLine)

        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
display
                End If
                Dim prod As IMessageProducer = session.CreateProducer(New
Commands.ActiveMQQueue(DEST))
                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)
                prod.Send(msg)

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

End Module


--
View this message in context: http://activemq.2283324.n4.nabble.com/IConnection-start-optional-tp3397472p3397472.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message