1 Reply Latest reply on Oct 24, 2013 2:09 PM by D G

    how to create temporary queues from a plain C# client?

    D G Newbie

      Hello, forgive my newbishness here - I have the feeling I'm missing something obvious - but I've been tearing my hair out over this for a while now, so any help would be much appreciated!


      Use case

      • jboss EAP 6.1 server
      • I have C# clients that want to be notified of things instantly by the server (i.e. I don't want to frequently poll the server)
      • I want to be sure that no maliciously created client can read messages intended for a different client

       

      What I have so far

      JMS/HornetQ seems like the perfect answer for instant notification, so to tackle the Java<->C# interoperability issue I've opted for the STOMP protocol. I've got this working with a simple C# client along the lines of:

       

              public JMSConnector(string ip, int port, string username, string password)
              {
                  socket = CreateSocket(ip, port);
                  stream = new NetworkStream(socket);
                  
                  Connect(username, password);
              }
              
              private Socket CreateSocket(string ip, int port)
              {
                  IPHostEntry hostEntry = Dns.GetHostEntry(ip);
      
                  foreach (IPAddress address in hostEntry.AddressList)
                  {
                      Socket socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                      socket.Connect(new IPEndPoint(address, port));
                      
                      if (socket.Connected) return socket;
                  }
                  throw new SocketException();
              }
              
              private void Connect(string username, string password)
              {
                  byte[] message = System.Text.UTF8Encoding.UTF8.GetBytes("CONNECT\u000alogin: " + username.Trim() + "\u000apasscode:" + password + "\u000a\u000a\u0000");
                  
                  stream.Write(message, 0, message.Length);
                  stream.Flush();
              }
      

       

      This works just fine and I can send messages to a predefined Queue and get a receipt from it.

       

      The problem is that I can't see a way for the client to act as a consumer for a queue. If I understand it correctly, only the creator of a temporary queue can act as the consumer, so how do I achieve that in a simple C# client that doesn't have access to hornet's client jar files?

      I did try to send a "reply-to" header in a message with a value of "/temp-queue/myqueue" in the hope that my MDB could tell HornetQ to create this and subscribe the client to it as the only consumer, but it just moaned at me that it doesn't exist

       

      I think the answer will be that it's a feature not yet implemented, but I thought I'd ask in case I'm missing a better solution. It's early days so it's fine to drop STOMP (or even JMS) for something else if it can fit the use case.

       

      I hope you can help!