You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by MikeyBoy <fj...@yahoo.com> on 2006/09/25 21:02:03 UTC

C# NMS client

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#a6493106
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Where is DLL?

Posted by MikeyBoy <fj...@yahoo.com>.
Thanks James for the information. I was able to build activemq-dotnet.dll and
built a small test application. I fixed the problems with the 2 missing
files (ConnectionControlMarshaller.cs and ConsumerControlMarshaller.cs). If
anyone is interested they can download it from below. This is a zip file
which contains an activemq-dotnet project (which crates the dll) and a
project called TestNMS which tests a consumer and producer and includes a
reference to the activemq-dotnet.dll file. Download here:

http://www.olsendarter.org/dev/activemq-dotnet.zip

Also, you must download NUnit and install it as it is included as a
reference.  See :

http://www.nunit.org/

I hope this saves someone some time.  

M


James.Strachan wrote:
> 
> On 9/26/06, MikeyBoy <fj...@yahoo.com> wrote:
>>
>> Hi Rob, forgive my ignorance, I'm just starting out with ActiveMQ. I am
>> puzzled where the activemq-dotnet.dll file you mentioned comes from. I
>> built
>> my own NMS.dll file using MSVS using just the NMS source, which does not
>> contain any ActiveMQ namespace. Do I also need to build
>> activemq-dotnet.dll?
>> Are the DLLs available for download anywhere? I'm missing something
>> here...TIA, M
> 
> There's currently no DLL to download (unfortunately we're still
> waiting for the maven csharp plugin to be fixed) - but you can build
> it yourself using NAnt as described here...
> http://incubator.apache.org/activemq/nms.html
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

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


Re: Where is DLL?

Posted by James Strachan <ja...@gmail.com>.
On 9/26/06, MikeyBoy <fj...@yahoo.com> wrote:
>
> Hi Rob, forgive my ignorance, I'm just starting out with ActiveMQ. I am
> puzzled where the activemq-dotnet.dll file you mentioned comes from. I built
> my own NMS.dll file using MSVS using just the NMS source, which does not
> contain any ActiveMQ namespace. Do I also need to build activemq-dotnet.dll?
> Are the DLLs available for download anywhere? I'm missing something
> here...TIA, M

There's currently no DLL to download (unfortunately we're still
waiting for the maven csharp plugin to be fixed) - but you can build
it yourself using NAnt as described here...
http://incubator.apache.org/activemq/nms.html
-- 

James
-------
http://radio.weblogs.com/0112098/

Where is DLL?

Posted by MikeyBoy <fj...@yahoo.com>.
Hi Rob, forgive my ignorance, I'm just starting out with ActiveMQ. I am
puzzled where the activemq-dotnet.dll file you mentioned comes from. I built
my own NMS.dll file using MSVS using just the NMS source, which does not
contain any ActiveMQ namespace. Do I also need to build activemq-dotnet.dll?
Are the DLLs available for download anywhere? I'm missing something
here...TIA, M


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


Re: C# NMS client

Posted by Rob Lugt <ro...@cheynecapital.com>.
I like the fact they're now separate.  It makes the whole C# client much
cleaner.

My 2c
~Rob


James.Strachan wrote:
> 
> On 10/4/06, Oleg Deribas <th...@td.selfip.net> wrote:
>> Hello,
>>
>> James Strachan said the following on 28.09.2006 9:14:
>>
>> > It'd be good if windows/.net folks could just add ActiveMQ.DLL for
>> > using ActiveMQ and NMS-MSMQ.DLL for accessing MSMQ maybe? I wonder if
>> > it'd be nice to include the NMS API inside the 2 DLLs?
>>
>> But what if you'll need to use both protocols in application?
> 
> Good point - I guess they should stay separate.
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

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


Re: C# NMS client

Posted by James Strachan <ja...@gmail.com>.
On 10/4/06, Oleg Deribas <th...@td.selfip.net> wrote:
> Hello,
>
> James Strachan said the following on 28.09.2006 9:14:
>
> > It'd be good if windows/.net folks could just add ActiveMQ.DLL for
> > using ActiveMQ and NMS-MSMQ.DLL for accessing MSMQ maybe? I wonder if
> > it'd be nice to include the NMS API inside the 2 DLLs?
>
> But what if you'll need to use both protocols in application?

Good point - I guess they should stay separate.

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: C# NMS client

Posted by Oleg Deribas <th...@td.selfip.net>.
Hello,

James Strachan said the following on 28.09.2006 9:14:

> It'd be good if windows/.net folks could just add ActiveMQ.DLL for
> using ActiveMQ and NMS-MSMQ.DLL for accessing MSMQ maybe? I wonder if
> it'd be nice to include the NMS API inside the 2 DLLs?

But what if you'll need to use both protocols in application?

-- 
Oleg


Re: C# NMS client

Posted by James Strachan <ja...@gmail.com>.
On 9/28/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
> Hi James,
>
> That sounded like such a good idea that I started working on it.

Awesome! :)

> Before I get too far into it, I'm starting to realize that it would be
> a bad idea if I just dumped an implementation for MSMQ into the
> current code base since then the code would probably not compile or be
> testable on non-windows platforms.  Would this be a problem?
>
> If we do go with breaking this out to separate module, I think the NMS
> name space should be it's own module too.

Yeah, good idea.

It'd be good if windows/.net folks could just add ActiveMQ.DLL for
using ActiveMQ and NMS-MSMQ.DLL for accessing MSMQ maybe? I wonder if
it'd be nice to include the NMS API inside the 2 DLLs?

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: C# NMS client

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Hi James,

That sounded like such a good idea that I started working on it.
Before I get too far into it, I'm starting to realize that it would be
a bad idea if I just dumped an implementation for MSMQ into the
current code base since then the code would probably not compile or be
testable on non-windows platforms.  Would this be a problem?

If we do go with breaking this out to separate module, I think the NMS
name space should be it's own module too.

On 9/26/06, James Strachan <ja...@gmail.com> wrote:
>
> Hopefully someone could write an MSMQ implementation of NMS too; then
> folks could switch between various messaging providers using the same
> NMS API.
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Re: C# NMS client

Posted by James Strachan <ja...@gmail.com>.
On 9/25/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
> On 9/25/06, Rob Lugt <ro...@cheynecapital.com> wrote:
> >
> >
> > MikeyBoy wrote:
> > >
> > > Hi Rob that's for the reply. Somehow I assumed NMS could be used as a
> > > stand-alone client. I looked at the ActiveMQ Windows binary and see it
> > > contains no DLLs, just JARs. So do I need to build an ActiveMQ DLL
> > > callable from .net?  TIA, M
> > >
> >
> > Hi Mike
> >
> > No, the activemq-dotnet DLL contains two top-level namespaces: NMS and
> > ActiveMQ; I'm not sure of the rationale for this. If you view the DLL in
>
> The reason for the 2 namespaces is that the interfaces in NMS name
> space can be implemented by other messaging systems and is not
> ActiveMQ specific.
>
> The ActiveMQ namespace has our implementation of the interfaces in the
> NMS namespace.

Hopefully someone could write an MSMQ implementation of NMS too; then
folks could switch between various messaging providers using the same
NMS API.

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: C# NMS client

Posted by Hiram Chirino <hi...@hiramchirino.com>.
On 9/25/06, Rob Lugt <ro...@cheynecapital.com> wrote:
>
>
> MikeyBoy wrote:
> >
> > Hi Rob that's for the reply. Somehow I assumed NMS could be used as a
> > stand-alone client. I looked at the ActiveMQ Windows binary and see it
> > contains no DLLs, just JARs. So do I need to build an ActiveMQ DLL
> > callable from .net?  TIA, M
> >
>
> Hi Mike
>
> No, the activemq-dotnet DLL contains two top-level namespaces: NMS and
> ActiveMQ; I'm not sure of the rationale for this. If you view the DLL in

The reason for the 2 namespaces is that the interfaces in NMS name
space can be implemented by other messaging systems and is not
ActiveMQ specific.

The ActiveMQ namespace has our implementation of the interfaces in the
NMS namespace.  If you use an object factory that creates the initial
ConnectionFactory for you, then your application code can stay
decoupled from ActiveMQ since it only needs to use the interfaces in
the NMS namespace.  But that can be a little tricky to setup, so most
folks just import the ConnectionFactory from activemq namespace
directly.

> VS.Net object browser you'll see all the namespaces it contains.
>
> You simply need to reference the DLL (which you're already doing I believe)
> and include the line:
>
> using ActiveMQ;
>
> in your source.
>
> Hope this helps
> Regards
> ~Rob
>
> --
> View this message in context: http://www.nabble.com/C--NMS-client-tf2333701.html#a6495629
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Re: C# NMS client

Posted by Rob Lugt <ro...@cheynecapital.com>.

MikeyBoy wrote:
> 
> Hi Rob that's for the reply. Somehow I assumed NMS could be used as a
> stand-alone client. I looked at the ActiveMQ Windows binary and see it
> contains no DLLs, just JARs. So do I need to build an ActiveMQ DLL
> callable from .net?  TIA, M
> 

Hi Mike

No, the activemq-dotnet DLL contains two top-level namespaces: NMS and
ActiveMQ; I'm not sure of the rationale for this. If you view the DLL in
VS.Net object browser you'll see all the namespaces it contains.

You simply need to reference the DLL (which you're already doing I believe)
and include the line:

using ActiveMQ;

in your source.

Hope this helps
Regards
~Rob

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


Re: C# NMS client

Posted by MikeyBoy <fj...@yahoo.com>.
Hi Rob that's for the reply. Somehow I assumed NMS could be used as a
stand-alone client. I looked at the ActiveMQ Windows binary and see it
contains no DLLs, just JARs. So do I need to build an ActiveMQ DLL callable
from .net?  TIA, M





Rob Lugt wrote:
> 
> 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#a6494592
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: C# NMS client

Posted by Rob Lugt <ro...@cheynecapital.com>.
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.