MSMQ problem?

Last post 11-05-2009 7:02 PM by anup1252000. 4 replies.

Sort Posts:

  • MSMQ problem?

    11-01-2009, 8:21 PM
    • Member
      212 point Member
    • jakein2008
    • Member since 08-26-2007, 11:41 AM
    • Posts 349

    My asp.net web application use MSMQ , how to access MSMQ and create a private message in MSMQ in window server 2008?


    Thanks.

  • Re: MSMQ problem?

    11-01-2009, 8:36 PM
    Answer
    • Participant
      1,686 point Participant
    • atifsarfraz
    • Member since 10-06-2009, 7:55 PM
    • Florida
    • Posts 269

    Here is a sample


    Dim objQueueServer As MessageQueue 
    strPath = "FormatName:DIRECT=OS:SERVER_NAME\private$\PRIVATE_QUEUE_NAME"
                                ' open exiting queue
                                objQueueServer = New MessageQueue(strPath)
                                ' set formatter
                                objQueueServer.Formatter = objMessageFormatter
                                ' send message
                                Dim resMessage As New Message(strMessage)
                                resMessage.Recoverable = True
                                objQueueServer.Send(resMessage, strLabel)
    ' send message
                                Dim resMessage As New Message(strMessage)
                                resMessage.Recoverable = True
                                objQueueServer.Send(resMessage, strLabel)

                               Dim objQueueServer As MessageQueue 
                               strPath = "FormatName:DIRECT=OS:SERVER_NAME\private$\PRIVATE_QUEUE_NAME"
    
                                ' open exiting queue
                                objQueueServer = New MessageQueue(strPath)
    
                                ' set formatter if required
                                ' objQueueServer.Formatter = objMessageFormatter 
    
                                ' send message
                                Dim resMessage As New Message(strMessage)
                                resMessage.Recoverable = True
    
                                objQueueServer.Send(resMessage, strLabel)
    
    

    Regards,

    Atif Sarfraz

    Please mark this post as answered if it helped you!
  • Re: MSMQ problem?

    11-02-2009, 9:16 AM
    • Member
      212 point Member
    • jakein2008
    • Member since 08-26-2007, 11:41 AM
    • Posts 349

    Hi, thank you for your answer.


    But from where I can see the private message after it was created in window server 2008?


    Thanks in advance.

  • Re: MSMQ problem?

    11-02-2009, 10:26 AM
    Answer
    • Participant
      1,686 point Participant
    • atifsarfraz
    • Member since 10-06-2009, 7:55 PM
    • Florida
    • Posts 269

    I am running a windows 2003 server and here is where you find the messages

    Computer Managemenet -> Services and Applications --> Message Queuing --> Private Queues --> Queue_Name


    Ofcourse you need to have message queuing installed first.

    Regards,

    Atif Sarfraz

    Please mark this post as answered if it helped you!
  • Re: MSMQ problem?

    11-05-2009, 7:02 PM
    Answer
    • Contributor
      2,512 point Contributor
    • anup1252000
    • Member since 11-12-2008, 8:26 AM
    • india
    • Posts 505

    Here i am using WCF

    server:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ServiceModel;
    using System.Messaging;
    using System.Configuration;
    namespace ConsoleApplication3
    {
        [ServiceContract]
        public interface iservice
        {
            [OperationContract(IsOneWay=true)]
            void operation();
        }
        public class Service : iservice
        {
            #region iservice Members
            public void operation()
            {
                Console.WriteLine("hi");
            }
            #endregion
        }
        class Program
        {
            static void Main(string[] args)
            {
                string queuename=ConfigurationManager.AppSettings["queuename"];
                Uri httpaddress = new Uri("http://localhost:8003/Service");
                if (!MessageQueue.Exists(queuename))
                {
                    MessageQueue.Create(queuename);
                }
                ServiceHost host = new ServiceHost(typeof(Service), httpaddress);
                host.Open();
                Console.WriteLine("host opening");
                Console.ReadLine();
                host.Close();
            }
        }
    }

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.ServiceModel;

    using System.Messaging;

    using System.Configuration;


    namespace ConsoleApplication3

    {

        [ServiceContract]

        public interface iservice

        {

            [OperationContract(IsOneWay=true)]

            void operation();

        }


        public class Service : iservice

        {

            #region iservice Members


            public void operation()

            {

                Console.WriteLine("hi");

            }


            #endregion

        }

        class Program

        {

            static void Main(string[] args)

            {

                string queuename=ConfigurationManager.AppSettings["queuename"];

                Uri httpaddress = new Uri("http://localhost:8003/Service");

                if (!MessageQueue.Exists(queuename))

                {

                    MessageQueue.Create(queuename);

                }

                ServiceHost host = new ServiceHost(typeof(Service), httpaddress);

                host.Open();

                Console.WriteLine("host opening");

                Console.ReadLine();

                host.Close();

            }

        }

    }


    app.config for server
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <netMsmqBinding>
                    <binding name="NewBinding0" exactlyOnce="false" >
                        <security mode="None" />
                    </binding>
                </netMsmqBinding>
            </bindings>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="NewBehavior">
                        <serviceMetadata httpGetEnabled="true" />
                        <serviceThrottling />
                    </behavior>
                </serviceBehaviors>
            </behaviors>
            <services>
                <service behaviorConfiguration="NewBehavior" name="ConsoleApplication3.Service">
                    <endpoint address="net.msmq://ahosur1/private/anup" binding="netMsmqBinding"
                        bindingConfiguration="NewBinding0" contract="ConsoleApplication3.iservice" />
                    <endpoint binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
                </service>
            </services>
        </system.serviceModel>
      <appSettings>
        <add key="queuename" value="ahosur1\private$\anup"/>
      </appSettings> 
    </configuration>

    after this u need to run svcutil tool

    client:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication5
    {
        class Program
        {
            static void Main(string[] args)
            {
                iserviceClient proxy = new iserviceClient();
                proxy.operation();
                Console.WriteLine("client completed");
                Console.ReadLine();
            }
        }
    }

    client app.config:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <netMsmqBinding>
                    <binding name="NetMsmqBinding_iservice" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        deadLetterQueue="System" durable="true" exactlyOnce="false"
                        maxReceivedMessageSize="65536" maxRetryCycles="2" receiveErrorHandling="Fault"
                        receiveRetryCount="5" retryCycleDelay="00:30:00" timeToLive="1.00:00:00"
                        useSourceJournal="false" useMsmqTracing="false" queueTransferProtocol="Native"
                        maxBufferPoolSize="524288" useActiveDirectory="false">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                            <transport msmqAuthenticationMode="WindowsDomain" msmqEncryptionAlgorithm="RC4Stream"
                                msmqProtectionLevel="Sign" msmqSecureHashAlgorithm="Sha1" />
                            <message clientCredentialType="Windows" />
                        </security>
                    </binding>
                </netMsmqBinding>
            </bindings>
            <client>
                <endpoint address="net.msmq://machinename/private/anup" binding="netMsmqBinding"
                    bindingConfiguration="NetMsmqBinding_iservice" contract="iservice"
                    name="NetMsmqBinding_iservice" />
            </client>
        </system.serviceModel>
    </configuration>

    in the endpoint address u need to specify ur computer name in place of m/c name.

    Remember to click “Mark as Answer” on the post, if it helps you. Because It helps others to find the solution.

    Anup Hosur
    HP
    http://anup-anuphosur.blogspot.com/


Page 1 of 1 (5 items)