]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/contrib/Rebus/Program.cs
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / jaegertracing / thrift / contrib / Rebus / Program.cs
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20 using Rebus.Configuration;
21 using Rebus.RabbitMQ;
22 using System;
23 using System.Collections.Generic;
24 using System.Linq;
25 using System.Text;
26 using System.Threading.Tasks;
27 using RebusSample.Client;
28 using RebusSample.Server;
29
30 namespace RebusSample
31 {
32 class Program
33 {
34 static BuiltinContainerAdapter StartRequestServer(string server)
35 {
36 // client Rebus configuration
37 var adapter = new BuiltinContainerAdapter();
38 Configure.With(adapter)
39 .Transport(t => t.UseRabbitMq("amqp://" + server, "MathRequests", "MathRequestErrors"))
40 .MessageOwnership(o => o.FromRebusConfigurationSection())
41 .CreateBus().Start();
42
43 // register all relevant message handlers
44 adapter.Register(typeof(MathRequestCallHandler));
45 return adapter;
46 }
47
48
49 static BuiltinContainerAdapter StartResponseServer(string server)
50 {
51 // client Rebus configuration
52 var adapter = new BuiltinContainerAdapter();
53 Configure.With(adapter)
54 .Transport(t => t.UseRabbitMq("amqp://" + server, "MathResponses", "MathResponseErrors"))
55 .MessageOwnership(o => o.FromRebusConfigurationSection())
56 .CreateBus().Start();
57
58 // register all relevant message handlers
59 adapter.Register(typeof(MathResponseCallHandler));
60 return adapter;
61 }
62
63 static void Main(string[] args)
64 {
65 string server = "localhost";
66
67 // start all servers
68 var req = StartRequestServer(server);
69 var rsp = StartResponseServer(server);
70
71 // send the first message
72 var random = new Random();
73 var client = new MathRequestClient(server);
74 client.DoTheMath(random.Next(), random.Next());
75
76 // now what?
77 Console.Write("Hit <ENTER> to stop ... ");
78 Console.ReadLine();
79 }
80 }
81 }