Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Why *does* this work, and when will it *not* work? (Two-way MSMQ messaging using WCF)

Why *does* this work, and when will it *not* work? (Two-way MSMQ messaging using WCF)

Scheduled Pinned Locked Moved C#
csharpwcfsysadminsecuritydebugging
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Furty
    wrote on last edited by
    #1

    I've been experimenting with various implementations of two-way communications using WCF over MSMQ, and without ever thinking it would work, tried the following:

    using System;
    using System.ServiceModel;

    namespace MessagingSample
    {
    [ServiceContract]
    public interface ISampleContract
    {
    [OperationContract(IsOneWay = true)]
    void StartDoingSomething(string someText, SampleClient client);
    }

    \[ServiceBehavior\]
    public class SampleClient
    {
        private ISampleContract workerService;
    
        public void StartClient(string server)
        {
            // Init the service instance
            EndpointAddress endpointAddress = new EndpointAddress(
                new Uri(string.Format(@"net.msmq://{0}/private/SampleQueue", server)));
    
            NetMsmqBinding clientBinding = new NetMsmqBinding();
            clientBinding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None;
            clientBinding.Security.Transport.MsmqProtectionLevel = System.Net.Security.ProtectionLevel.None;
    
            ChannelFactory<ISampleContract> channelFactory =
                new ChannelFactory<ISampleContract>(clientBinding, endpointAddress);
            workerService = channelFactory.CreateChannel();
    
        }
    
        public void StopClient()
        {
            if (workerService != null)
            {
                workerService = null;
            }
        }
    
        public void StartDoingSomething(string text)
        {
            if (workerService != null)
            {
                workerService.StartDoingSomething(text, this);
            }
        }
    
        public void DoSomethingElse(string text)
        {
            System.Diagnostics.Debug.WriteLine(text);
        }
    }
    
    
    \[ServiceBehavior\]
    public class SampleServer : ISampleContract
    {
        private ServiceHost serviceHost = null;
    
        public void StartServer(string server)
        {
            Uri serviceUri = new Uri(string.Format(@"net.msmq://{0}/private/SampleQueue", server));
    
            NetMsmqBinding serviceBinding = new NetMsmqBinding();
            serviceBinding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None;
            serviceBinding.Security.Transport.MsmqProtectionLevel = System.Net.Security.ProtectionLevel.None;
            serviceBinding.MaxReceivedMessageSize = 1024 \* 4096;
            serviceBinding.ReaderQuotas.MaxArrayLength = 1024 \* 4096;
    
    M 1 Reply Last reply
    0
    • F Furty

      I've been experimenting with various implementations of two-way communications using WCF over MSMQ, and without ever thinking it would work, tried the following:

      using System;
      using System.ServiceModel;

      namespace MessagingSample
      {
      [ServiceContract]
      public interface ISampleContract
      {
      [OperationContract(IsOneWay = true)]
      void StartDoingSomething(string someText, SampleClient client);
      }

      \[ServiceBehavior\]
      public class SampleClient
      {
          private ISampleContract workerService;
      
          public void StartClient(string server)
          {
              // Init the service instance
              EndpointAddress endpointAddress = new EndpointAddress(
                  new Uri(string.Format(@"net.msmq://{0}/private/SampleQueue", server)));
      
              NetMsmqBinding clientBinding = new NetMsmqBinding();
              clientBinding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None;
              clientBinding.Security.Transport.MsmqProtectionLevel = System.Net.Security.ProtectionLevel.None;
      
              ChannelFactory<ISampleContract> channelFactory =
                  new ChannelFactory<ISampleContract>(clientBinding, endpointAddress);
              workerService = channelFactory.CreateChannel();
      
          }
      
          public void StopClient()
          {
              if (workerService != null)
              {
                  workerService = null;
              }
          }
      
          public void StartDoingSomething(string text)
          {
              if (workerService != null)
              {
                  workerService.StartDoingSomething(text, this);
              }
          }
      
          public void DoSomethingElse(string text)
          {
              System.Diagnostics.Debug.WriteLine(text);
          }
      }
      
      
      \[ServiceBehavior\]
      public class SampleServer : ISampleContract
      {
          private ServiceHost serviceHost = null;
      
          public void StartServer(string server)
          {
              Uri serviceUri = new Uri(string.Format(@"net.msmq://{0}/private/SampleQueue", server));
      
              NetMsmqBinding serviceBinding = new NetMsmqBinding();
              serviceBinding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None;
              serviceBinding.Security.Transport.MsmqProtectionLevel = System.Net.Security.ProtectionLevel.None;
              serviceBinding.MaxReceivedMessageSize = 1024 \* 4096;
              serviceBinding.ReaderQuotas.MaxArrayLength = 1024 \* 4096;
      
      M Offline
      M Offline
      Meer Osman Ali
      wrote on last edited by
      #2

      Try coding it in Java. C# sucks big time. May Allah give you the knowledge

      F L 2 Replies Last reply
      0
      • M Meer Osman Ali

        Try coding it in Java. C# sucks big time. May Allah give you the knowledge

        F Offline
        F Offline
        Furty
        wrote on last edited by
        #3

        The operative word there being try, of course. P.S. Do you always submit message board posts that make you sound like a total moron, or was this just an isolated instance?

        M D 2 Replies Last reply
        0
        • F Furty

          The operative word there being try, of course. P.S. Do you always submit message board posts that make you sound like a total moron, or was this just an isolated instance?

          M Offline
          M Offline
          Meer Osman Ali
          wrote on last edited by
          #4

          Furty wrote:

          Do you always submit message board posts that make you sound like a total moron, or was this just an isolated instance?

          Dude i was showing u the right path for programming

          F 1 Reply Last reply
          0
          • M Meer Osman Ali

            Furty wrote:

            Do you always submit message board posts that make you sound like a total moron, or was this just an isolated instance?

            Dude i was showing u the right path for programming

            F Offline
            F Offline
            Furty
            wrote on last edited by
            #5

            Meer Osman Ali wrote:

            Dude i was showing u the right path for programming

            Right. Gotcha. I had you pegged as a trolling wanker, but thanks for the confirmation!

            M P 2 Replies Last reply
            0
            • F Furty

              Meer Osman Ali wrote:

              Dude i was showing u the right path for programming

              Right. Gotcha. I had you pegged as a trolling wanker, but thanks for the confirmation!

              M Offline
              M Offline
              Meer Osman Ali
              wrote on last edited by
              #6

              Furty wrote:

              I had you pegged as a trolling wanker, but thanks for the confirmation!

              :-D Gee have a nice day then

              1 Reply Last reply
              0
              • M Meer Osman Ali

                Try coding it in Java. C# sucks big time. May Allah give you the knowledge

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Allah has given us C#. Java is an abomination to Allah, a heretic language. Are you rally suggesting that we ignore the progress that He has granted us? Ignore type-safety? Drop the increased productivity? That sounds like the arrogance that Iblis would display :omg: As Spock would say, "Live long and prosper" :-D

                1 Reply Last reply
                0
                • F Furty

                  The operative word there being try, of course. P.S. Do you always submit message board posts that make you sound like a total moron, or was this just an isolated instance?

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  No, pretty much every post he's made is from a completely ignorant viewpoint.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                       2006, 2007, 2008

                  1 Reply Last reply
                  0
                  • F Furty

                    Meer Osman Ali wrote:

                    Dude i was showing u the right path for programming

                    Right. Gotcha. I had you pegged as a trolling wanker, but thanks for the confirmation!

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #9

                    If it farts like a troll, smells like a troll, and looks like a troll, shouldn't we just castrate it?

                    Deja View - the feeling that you've seen this post before.

                    My blog | My articles | MoXAML PowerToys

                    L 1 Reply Last reply
                    0
                    • P Pete OHanlon

                      If it farts like a troll, smells like a troll, and looks like a troll, shouldn't we just castrate it?

                      Deja View - the feeling that you've seen this post before.

                      My blog | My articles | MoXAML PowerToys

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #10

                      Absolutely not. It would fart, smell and look like a troll even more, and scream its heart out on top of that. On the other hand, if it intends to procreate, you would have to accept these short-term disadvantages, and go for the long-term benefits. Or act a little more effectively and solve the problem once and forever. :) PS: nothing much has changed around here, has it?

                      Luc Pattyn [Forum Guidelines] [My Articles]


                      Fixturized forever. :confused:


                      P 1 Reply Last reply
                      0
                      • L Luc Pattyn

                        Absolutely not. It would fart, smell and look like a troll even more, and scream its heart out on top of that. On the other hand, if it intends to procreate, you would have to accept these short-term disadvantages, and go for the long-term benefits. Or act a little more effectively and solve the problem once and forever. :) PS: nothing much has changed around here, has it?

                        Luc Pattyn [Forum Guidelines] [My Articles]


                        Fixturized forever. :confused:


                        P Offline
                        P Offline
                        Pete OHanlon
                        wrote on last edited by
                        #11

                        Luc Pattyn wrote:

                        PS: nothing much has changed around here, has it?

                        Same ol', same ol'. Mind you, I've spent the last month or so working on a bit of Open Source work along with Karl Shifflett, so I've spent less time in the forums as a result.

                        Deja View - the feeling that you've seen this post before.

                        My blog | My articles | MoXAML PowerToys

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups