[rabbitmq-discuss] how to make Wcf bind to rabbitmq exchange and queue?
    Wilson Ke 
    wilson.ke at wealthcraft.com
       
    Thu Jul 16 02:36:38 BST 2009
    
    
  
Dear all,
     Thanks for your reply. But I have read doc and example code for several times. But can't fine answer. I want to use Wcf to bind the special queue by queue name, just like below code. But I want to use Wcf to implement. Could you show some sample code
        private int SendString(string message)
        {
            try
            {
                string serverAddress = "192.168.1.87";
                string exchange = "yourexchange";
                string exchangeType = ExchangeType.Topic;
                string routingKey = "key";
                using (IConnection conn = new ConnectionFactory().CreateConnection(serverAddress))
                {
                    using (IModel ch = conn.CreateModel())
                    {
                        if (exchange != "")
                        {
                            ch.ExchangeDeclare(exchange, exchangeType,true,false,false,false,false,null);
                        }
                        ch.QueueBind("subscriptionqueue", exchange, routingKey, false, null);//how to bind by using Wcf?
                        ch.BasicPublish(exchange,
                                        routingKey,
                                        null,
                                        Encoding.UTF8.GetBytes(message));
                        return 0;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return 2;
            }
        }
-----Original Message-----
From: Alexis Richardson [mailto:alexis.richardson at gmail.com]
Sent: 2009年7月15日 18:47
To: Wilson Ke
Cc: rabbitmq-discuss
Subject: Re: [rabbitmq-discuss] how to make Wcf bind to rabbitmq exchange and queue?
Wilson
Have you read the documentation -- eg. the PDFs -- on this page?
http://www.rabbitmq.com/dotnet.html
alexis
On Wed, Jul 15, 2009 at 11:43 AM, Wilson Ke<wilson.ke at wealthcraft.com> wrote:
> Hi all,
>
>      I am use Wcf and RabbitMQ to make project.  I can use Wcf bind RabbitMQ
> to work normal as below ,but I don’t know how to make Wcf bind to rabbitmq
> exchange and queue, could you help me? Many thanks!
>
>
>
> C# code:
>
> namespace Server
>
> {
>
>     using System;
>
>     using System.ServiceModel;
>
>     using WcfServiceLibrary1;
>
>     using RabbitMQ.ServiceModel;
>
>
>
>     class Server
>
>     {
>
>         public void Run()
>
>         {
>
>
>
>
>
>
>
>             ServiceHost host = new ServiceHost(typeof(HelloService));
>
>             host.Open();
>
>
>
>             Console.WriteLine("Service Ready");
>
>             Console.ReadLine();
>
>
>
>             host.Close();
>
>         }
>
>     }
>
> }
>
>
>
> Config file:
>
> <?xml version="1.0" encoding="utf-8" ?>
>
> <configuration>
>
>   <system.serviceModel>
>
>
>
>     <services>
>
>       <service name="WcfServiceLibrary1.HelloService">
>
>         <host>
>
>           <baseAddresses>
>
>             <add baseAddress="soap.amqp:///"   />
>
>           </baseAddresses>
>
>         </host>
>
>         <endpoint
>
>           address="Hello"
>
>           binding="rabbitMQBinding"
>
>           bindingConfiguration="rabbitMQConfig"
>
>           contract="WcfServiceLibrary1.IHelloContract"/>
>
>       </service>
>
>     </services>
>
>     <bindings>
>
>       <rabbitMQBinding>
>
>         <binding name="rabbitMQConfig"
>
>           broker="amqp://192.168.1.87:5672/"
>
>           protocolversion="AMQP_0_8"
>
>          oneWay="false"
>
>                     />
>
>       </rabbitMQBinding>
>
>     </bindings>
>
>
>
>     <extensions>
>
>       <bindingExtensions>
>
>         <add
>
>           name="rabbitMQBinding"
>
>           type="RabbitMQ.ServiceModel.RabbitMQBindingSection,
> RabbitMQ.ServiceModel, Version=1.0.110.0, Culture=neutral,
> PublicKeyToken=null"/>
>
>       </bindingExtensions>
>
>     </extensions>
>
>
>
>   </system.serviceModel>
>
> </configuration>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20090716/df242863/attachment.htm 
    
    
More information about the rabbitmq-discuss
mailing list