コード例 #1
0
 RMQServiceBusInterface( ServiceBusClient dispatcher, TraceSource tracer )
 {
     if (dispatcher == null)
         throw new ArgumentNullException("entity");
     Process = dispatcher;
     this.Tracer = tracer;
 }
コード例 #2
0
 RMQServiceBusInterface(ServiceBusClient process, string exchange, string binding, TraceSource tracer)
 {
     if (process == null)
         throw new ArgumentNullException("service bus client");
     this.Process            =   process;
     this.Exchange           =   exchange;
     this.Binding            =   binding;
     this.Tracer             =   tracer;
 }
コード例 #3
0
ファイル: Bus.cs プロジェクト: rozacki/SimpleIPC
        /// <summary>        
        /// Create consumer that consumes on provided queue. The queue must exist and be bound to an exchange.
        /// It can be used to feed on fixed queues, I mean those that exists no matter if a consumer is attached to or not.
        /// By doing this we should expect a stream of events flowing to the dispatcher, which is process.
        /// </summary>
        /// <param name="process"></param>
        /// <param name="binding"></param>
        public static bool CreateConsumer( ServiceBusClient process, string queueName, string consumerTag )
        {
            //bind to external bus
            RMQServiceBusInterface busClient = (RMQServiceBusInterface)RMQBus.GetClient(process.Address);

            if (busClient != null)
            {
                if (!busClient.CreateConsumer(queueName, consumerTag))
                {
                    #warning handle this error properly
                    return false;
                }
            }
            Tracer.TraceEvent ( TraceEventType.Verbose,0, "[{0}] internal queue bound {1} ", process, queueName );
            return true;
        }
コード例 #4
0
 /// <summary>
 /// 
 /// </summary>
 public static RMQServiceBusInterface CreateProcess(ServiceBusClient process, string binding, TraceSource tracer)
 {
     return new RMQServiceBusInterface(process, "amq.topic", binding, tracer);
 }
コード例 #5
0
 /// <summary>
 /// 
 /// </summary>
 public static RMQServiceBusInterface CreateProcess(ServiceBusClient process, TraceSource tracer)
 {
     return new RMQServiceBusInterface(process, "amq.topic", process.Address, tracer);
 }
コード例 #6
0
ファイル: Bus.cs プロジェクト: rozacki/SimpleIPC
 /// <summary>
 /// Unbind exchange from the queue. By doing this we stop the message flow from both ipc and inproc channels.
 /// </summary>
 /// <param name="process"></param>
 /// <param name="binding"></param>
 public static void DestroyConsumer(ServiceBusClient process, string binding, string consumerTag)
 {
     //unbind from external bus
     RMQServiceBusInterface busProc = RMQBus.GetClient(process.Address);
     //if RMQ enabled then unbind from it
     if (busProc != null)
         busProc.DestroyConsumer ( consumerTag );
     Tracer.TraceEvent ( TraceEventType.Verbose, 0, "[{0}] internal queue unbound {1} ", process, binding );
 }
コード例 #7
0
ファイル: Bus.cs プロジェクト: rozacki/SimpleIPC
 public static void UnregisterProcess(ServiceBusClient process, string reason)
 {
     //bind to external bus
     RMQBus.UnregisterClient(process.Address, (ushort)RMQServiceBusInterface.ServiceBusCustomReasonCode.Dispose, reason);
 }
コード例 #8
0
ファイル: Bus.cs プロジェクト: rozacki/SimpleIPC
        /// <summary>
        /// TaskContinuationSources are kept in Broker. This function is called by DipatchMessage() to eventually finalize RPC request.
        /// <para>All rpc continuations are directed to processes/queues.</para>
        /// </summary>
        /// <param name="op"></param>
        /// <param name="correlationID"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static bool TryHandleAsRPCResponse( ServiceBusClient process, RequestData request )
        {
            if (request.Op == "rpc_response" || request.Op == "offer_accepted" || request.Op == "transfer_ack")
            {
                if (request.CorrelationId == null)
                {
                    //error
                    request.Ack(true, false);
                    Tracer.TraceEvent(TraceEventType.Error, 0, "[{0}] missing rpc task continuation cid, message dropped {1}", process, request.ToString());
                    return true;
                }
                TaskCompletionSource<object> tcs;
                //tracer...
                if (RPCTaskCompletions.TryRemove(request.CorrelationId, out tcs))
                {
                    try
                    {
                        tcs.TrySetResult(request.Response);
                        Tracer.TraceEvent(TraceEventType.Verbose, 0, "[{0}] rpc response op {1} cid {2} response {3}", process, request.Op, request.CorrelationId, request.Response);
                    }
                    catch (Exception ex)
                    {
                        Tracer.TraceEvent(TraceEventType.Error, 0, "[{0}] rpc response op {1} cid {2} response {3} failed dute to {4}", process, request.Op, request.CorrelationId, request.Response, ex.Message);
                    }

                    request.Ack(true, false);
                    return true;
                }
                else
                {
                    //probably result was already set, how did it happen that there are two responses to one request? are they different? possibly not but they could come because of network failue
                    //preserving at-least-once semantics; we ack and drop, making use of indemptodency
                    request.Ack(true, false);
                    Tracer.TraceEvent(TraceEventType.Error, 0, "[{0}] missing rpc task continuation for rpc response {1}, message dropped ", process, request.ToString());
                    return true;
                }
            }
            return false;
        }
コード例 #9
0
ファイル: Bus.cs プロジェクト: rozacki/SimpleIPC
 /// <summary>
 /// Register queue with different topic than the name of the process.
 /// </summary>
 /// <param name="process"></param>
 /// <param name="binding"></param>
 public static bool RegisterProcess(ServiceBusClient process, string binding)
 {
     //bind to external bus
     bool b  =   RMQBus.RegisterClient(process.Address, RMQServiceBusInterface.CreateProcess(process, binding, RMQBus.Tracer));
     if (b)
         Tracer.TraceEvent(TraceEventType.Information, 0, "New process: '{0}', RMQ topic {1}, registered, ", process.Address, binding);
     else
         Tracer.TraceEvent(TraceEventType.Information, 0, "New process: '{0}', RMQ topic {1} registeration failed", process.Address, binding);
     return b;
 }
コード例 #10
0
ファイル: Bus.cs プロジェクト: rozacki/SimpleIPC
 public static bool RegisterProcess( ServiceBusClient process)
 {
     //bind to external bus
     return RegisterProcess(process, process.Address);
 }