activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Lugt <robert.l...@cheynecapital.com>
Subject Re: C# NMS client
Date Mon, 25 Sep 2006 19:06:45 GMT

Hi Mike

ConnectionFactory is in the ActiveMQ namespace.

Regards
Rob Lugt


MikeyBoy wrote:
> 
> Hi, I'm attempting to write an NMS C# client. I just want to get a simple
> example client going. I have done the following:
> 
> 1) downloaded C# code from:
> https://svn.apache.org/repos/asf/incubator/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/
> 
> 2) placed above files (*.cs) in a project and built an NMS dll, which
> builds fine
> 
> 3) have created a 2nd VSCS project to test the NMS, which references
> NMS.dll. It includes the code from here:
> http://www.activemq.org/site/nms.html, which is also shown below.
> 
> 4) Question, when I try to build the code in 3) above (and shown below), I
> get an error..."ConnectionFactory" is not defined.  Where is it defined? I
> noticed IConnectionFactory is abstract...so somwhere it must be defined?
> 
> Thanks, MikeyBoy
> 
> ------code from http://www.activemq.org/site/nms.html:
> IConnectionFactory factory = new ConnectionFactory(new
> Uri("tcp://localhost:61616"));
> using (IConnection connection = factory.CreateConnection())
> {
>     Console.WriteLine("Created a connection!");
>     
>     ISession session = connection.CreateSession();
>     
>     IDestination destination = session.GetQueue("FOO.BAR");
>     Console.WriteLine("Using destination: " + destination);
>     
>     // lets create a consumer and producer
>     IMessageConsumer consumer = session.CreateConsumer(destination);
>     
>     IMessageProducer producer = session.CreateProducer(destination);
>     producer.Persistent = true;
>     
>     // lets send a message
>     ITextMessage request = session.CreateTextMessage("Hello World!");
>     request.NMSCorrelationID = "abc";
>     request.Properties["JMSXGroupID"] = "cheese";
>     request.Properties["myHeader"] = "James";
>     
>     producer.Send(request);
>     
>     // lets consume a message
>     ActiveMQTextMessage message = (ActiveMQTextMessage)
> consumer.Receive();
>     if (message == null)
>     {
>         Console.WriteLine("No message received!");
>     }
>     else
>     {
>         Console.WriteLine("Received message with ID:   " +
> message.NMSMessageId);
>         Console.WriteLine("Received message with text: " + message.Text);
>     }
> }
> 
> 

-- 
View this message in context: http://www.nabble.com/C--NMS-client-tf2333701.html#a6493191
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message