activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tammer Salem <tammer.sa...@googlemail.com>
Subject Re: Using NMS with .NET Compact Framework
Date Wed, 30 Dec 2009 14:05:11 GMT
Thanks Tim - I figured that NMS NETCF support was not completely implemented
- hence not supported.

I actually changed the implementation slightly and am getting errors trying
to find the nmsprovider-activemq.config file when debugging. The file is in
the same folder as the executable and it still says the file does not exist
- so I keep getting an exception:
No IConnectionFactory implementation found for connection URI:
activemq:tcp://192.168.1.118:80

Here is the code I'm trying to use:

========================================
using System;
using System.Threading;
using Apache.NMS;
using Apache.NMS.Util;

namespace Apache.NMS.ActiveMQ.Test
{
    public class TestMain
    {
        protected static AutoResetEvent semaphore = new
AutoResetEvent(false);
        protected static ITextMessage message = null;
        protected static TimeSpan receiveTimeout = TimeSpan.FromSeconds(10);

        public static void Main(string[] args)
        {

            Uri connecturi = new Uri("activemq:tcp://192.168.1.118:80");

            Console.WriteLine("About to connect to " + connecturi);

            IConnectionFactory factory = new
NMSConnectionFactory(connecturi);

            using (IConnection connection = factory.CreateConnection())
            using (ISession session = connection.CreateSession())
            {
                IDestination destination =
SessionUtil.GetDestination(session, "queue://FOO.BAR");
                Console.WriteLine("Using destination: " + destination);

                using (IMessageConsumer consumer =
session.CreateConsumer(destination))
                using (IMessageProducer producer =
session.CreateProducer(destination))
                {
                    connection.Start();     // Must start the connection for
async messaging.
                    producer.RequestTimeout = receiveTimeout;
                    consumer.Listener += new MessageListener(OnMessage);

                    // Send a message
                    ITextMessage request = session.CreateTextMessage("Hello
World!");
                    request.NMSCorrelationID = "abc";
                    request.Properties["NMSXGroupID"] = "cheese";
                    request.Properties["myHeader"] = "Cheddar";

                    producer.Send(request);

                    // Wait for the message
                    semaphore.WaitOne((int)receiveTimeout.TotalMilliseconds,
true);
                    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);
                    }
                }
            }
        }

        protected static void OnMessage(IMessage receivedMsg)
        {
            message = receivedMsg as ITextMessage;
            semaphore.Set();
        }
    }
}
====================================


If a stomp client is being worked on - I'll probably wait for that - in the
meantime I'm looking at using XMPP for NETCF with activemq.

Thanks for taking the time to respond - happy holidays everyone!


2009/12/25 Timothy Bish <tabish121@gmail.com>

> On Wed, Dec 23, 2009 at 9:47 PM, Tammer Salem
> <tammer.salem@googlemail.com>wrote:
>
> > Hello All,
> > I'm trying to create a .NET CF 2.0 application that can listen to
> messages
> > from activemq and update a UI based on the message.
> > I've been trying to get the IMessageConsumer interface working but for
> some
> > reason VS2008 doesn't recognize this as a valid interface from
> > the Apache.NMS.dll
> > Has anyone encountered this before?
> >
> >
> Your VS2008 project will need to reference both the NMS and NMS.ActiveMQ
> DLLs in order to work correctly.  That could be the issue, if you post a
> sample of you code I can tell you if there's any issue with your usage of
> the API.
>
>
> > Is this the accepted way of doing this? I'm not too bothered by the form
> of
> > communication, just the fact that I can create a listener on a separate
> > thread that can receive activemq messages.
> >
> > The documentation is very light, and I read a Nabble response saying that
> > .netcf is no longer supported? Can someone shed some light on this, and
> if
> > possible point me to some examples or documentation?
> >
>
>
> The ActiveMQ client no longer supports the .NETCF, work has started on a
> smaller Stomp based client that will work on .NETCF but its not yet
> complete.  You are welcome to contribute to the project if you'd like,
> currently basic functionality is there but things like transactions aren't
> tested yet and the code needs some work to build on the CF.
>
> I'd recommend that you get comfortable with the NMS.ActiveMQ client and
> hopefully the Stomp client will have a release out in the next month or so.
>
> Regards
> Tim.
>
>
>
>
> >
> > regards,
> > Tammer Salem
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message