activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: IConnection.start() - optional?
Date Tue, 22 Mar 2011 19:52:33 GMT
On Tue, 2011-03-22 at 12:21 -0700, olsonpm wrote:
> 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?

Connection start / stop applies only to the dispatch of Messages to
consumers.  A client can send messages without starting a Connection.

Regards
Tim

> 
> 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.

-- 
Tim Bish
------------
FuseSource
Email: tim.bish@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com/



Mime
View raw message